carbon-design-system/carbon-web-components — dự án UI/UX — đang có 475 sao GitHub trong nhóm UI / UX. Carbon Design System variant on top of Web Components
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Carbon Web Components is now part of the Carbon for IBM.com monorepo and will continue to have full official support by that team.
In addition, plans for January 2023 (first release candidate) will include :
Upgrade to Carbon v11
Upgrade to Lit v2
Upgrade to Typescript v4
With these upgrades, this will be a major version release to Carbon Web Components v2.
Plans to bring Carbon Web Components v2 to feature parity with Carbon React will occur throughout 2023.
If there are any questions, you can open an issue, reach out to us on Discord, or for IBMers can reach us at #carbon-for-ibm-dotcom on Slack!
A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.
Carbon is an open-source design system built by IBM. With the IBM Design
Language as its foundation, the system consists of working code, design tools
and resources, human interface guidelines, and a vibrant community of
contributors.
carbon-web-components
carbon-web-components is a variant of Carbon Design System with Custom Elements v1 and Shadow DOM v1 specs.
The effort stems from https://github.com/carbon-design-system/issue-tracking/issues/121. If you are interested in this project, adding 👍 to the description of that GH issue, or even contributing, will be greatly appreciated!
Getting started
Using CDN
How to install
Basic usage
Using ES imports
How to install
Basic usage
Other usage guides
JavaScript framework support
Angular
React
Vue
Getting started with development
Running React/Angular/Vue Storybook demo
List of available components
Browser support
Coding conventions
Creating build
Running unit test
Running build integration test
Running UI integration test
Getting started
Using CDN
How to install
All components are available via CDN. This means that they can be added to your application without the need of any
bundler configuration. Each component is available by the latest tag, or referencing a specific version (starting at
version v1.16.0):
<!-- By `latest` tag -->
<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/tag/latest/accordion.min.js"></script>
<!-- By specific version -->
<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/version/v1.16.0/accordion.min.js"></script>
These are the list of available components via CDN:
accordion.min.js
breadcrumb.min.js
button.min.js
checkbox.min.js
code-snippet.min.js
combo-box.min.js
content-switcher.min.js
copy-button.min.js
data-table.min.js
date-picker.min.js
dropdown.min.js
file-uploader.min.js
floating-menu.min.js
form.min.js
inline-loading.min.js
input.min.js
link.min.js
list.min.js
loading.min.js
modal.min.js
multi-select.min.js
notification.min.js
number-input.min.js
overflow-menu.min.js
pagination.min.js
progress-indicator.min.js
radio-button.min.js
search.min.js
select.min.js
skeleton-placeholder.min.js
skeleton-text.min.js
skip-to-content.min.js
slider.min.js
structured-list.min.js
tabs.min.js
tag.min.js
textarea.min.js
tile.min.js
toggle.min.js
tooltip.min.js
ui-shell.min.js
To use the right-to-left (RTL) version of the artifacts, change the file extention from .min.js to .rtl.min.js. For
example:
<!-- By `latest` tag (RTL) -->
<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/tag/latest/accordion.rtl.min.js"></script>
<!-- By specific version (RTL) -->
<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/version/v1.16.0/accordion.rtl.min.js"></script>
Basic usage
The CDN artifacts define the custom elements for the browser, so they can be directly used once the script tag has been
added to the page. For example:
<!DOCTYPE html>
<html>
<head>
<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/tag/latest/dropdown.min.js"></script>
<style type="text/css">
// Suppresses the custom element until it has been defined
bx-dropdown:not(:defined),
bx-dropdown-item:not(:defined) {
visibility: hidden;
}
</style>
</head>
<body>
<div id="app">
<bx-dropdown trigger-content="Select an item">
<bx-dropdown-item value="all">Option 1</bx-dropdown-item>
<bx-dropdown-item value="cloudFoundry">Option 2</bx-dropdown-item>
<bx-dropdown-item value="staging">Option 3</bx-dropdown-item>
<bx-dropdown-item value="dea">Option 4</bx-dropdown-item>
<bx-dropdown-item value="router">Option 5</bx-dropdown-item>
</bx-dropdown>
</div>
</body>
</html>
Our example at CodeSandbox shows usage with only CDN artifacts:
Using ES imports
How to install
To install carbon-web-components in your project, you will need to run the
following command using npm:
npm install --save carbon-web-components
If you prefer Yarn, use the following command
instead:
yarn add carbon-web-components
NOTE: Carbon and Lit dependencies will be managed by Carbon Web Components starting in
v1.19.0. For earlier versions, these dependencies will have to be installed
separately:
Our example at CodeSandbox shows the most basic usage:
The first thing you need is setting up a module bundler to resolve ECMAScript imports. The above example uses Webpack, but you can use other bundlers like Rollup too.
Once you set up a module bundler, you can start importing our component modules, for example:
Using carbon-web-components with old build toolchain
JavaScript framework support
In addition to the available Web Component versions of Carbon components, this
library also supports usage with JavaScript frameworks like Angular, React,
and Vue if the desire is to use instead of the pure framework versions of
Carbon components. Specifically for React, this library comes with a wrapper
implementation around the Carbon Web Components for more seamless integration
with your React application.
This is achievable since Web Components is the modern browser standard, and
works well with other front-end frameworks that exist in the application. In
turn, this also comes with the benefits of encapsulation within the Shadow DOM:
Angular
Angular users can use our components in the same manner as native HTML tags, too, once you add CUSTOM_ELEMENTS_SCHEMA schema to your Angular module, for example:
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [AppComponent],
imports: [BrowserModule],
bootstrap: [AppComponent],
})
export class AppModule {}
The .d.ts files in carbon-web-components package are compiled with TypeScript 3.7. You can use TypeScript 3.7 in your Angular application with upcoming Angular 9.0 release, or with the following instructions, so your application can use those .d.ts files:
Set true to angularCompilerOptions.disableTypeScriptVersionCheck in tsconfig.json
In polyfills.ts, change __importDefault TypeScript helper as follows: window.__importDefault = mod => (mod?.__esModule ? mod : { default: mod })
React
You can use wrapper React components in carbon-web-components/es/components-react generated automatically from the custom elements which allows you to use our components seamlessly in your React code. Here's an example:
import React from 'react';
import { render } from 'react-dom';
import BXDropdown from 'carbon-web-components/es/components-react/dropdown/dropdown.js';
import BXDropdownItem from 'carbon-web-components/es/components-react/dropdown/dropdown-item.js';
const App = () => (
<BXDropdown triggerContent="Select an item">
<BXDropdownItem value="all">Option 1</BXDropdownItem>
<BXDropdownItem value="cloudFoundry">Option 2</BXDropdownItem>
<BXDropdownItem value="staging">Option 3</BXDropdownItem>
<BXDropdownItem value="dea">Option 4</BXDropdownItem>
<BXDropdownItem value="router">Option 5</BXDropdownItem>
</BXDropdown>
);
render(<App />, document.getElementById('root'));
Note: Using the React wrapper requires an additional dependency, prop-types.
To run the wrapper React components in SSR environment requires Node 12.16.3 or above that supports "conditional mapping" feature:
Same Node version requirement applies to Next.js:
Vue
Vue users can use our components in the same manner as native HTML tags, without any additional steps!
View available web components at: https://web-components.carbondesignsystem.com/. You can see usage information in several ways:
Going to Docs tab, where it shows the usage and available attributes, properties and custom events.
Clicking the KNOBS tab at the bottom and changing values there. Most knobs are shown as something like Button kind (kind), where kind is the attribute name
Clicking the ACTION LOGGER tab at the bottom and interacting with the selected component. You may see something like bx-modal-closed which typically indicates that an event with such event type is fired. You can also expand the twistie to see the details of the event
Browser support
Latest Chrome/Safari/FF ESR
IE/Edge support is bast-effort basis
Some components may not be supported
To support IE, you need a couple additional setups:
Toolstack to re-transpile our code to ES5 (e.g. by specifying IE11 in @babel/preset-env configuration)
Polyfills, listed here
Here's an example code that shows such setup:
Coding conventions
Can be found at here.
Creating build
> yarn clean
> yarn build
You'll see the build artifacts in /path/to/carbon-web-components/es directory.
Running unit test
You can run unit test by:
> gulp test:unit
You can run specific test spec by:
> gulp test:unit -s tests/spec/dropdown_spec.ts
You can choose a browser (instead of Headless Chrome) by:
> gulp test:unit -b Firefox
You can keep the browser after the test (and re-run the test when files change) by:
> gulp test:unit -b Chrome -k
You can prevent code coverate instrumentation code from being generated by:
> gulp test:unit -d
You can update snapshots by:
> gulp test:unit --update-snapshot
Above options can be used together. This is useful to debug your code as you test:
carbon-design-system/carbon-web-components có bao nhiêu sao?
carbon-design-system/carbon-web-components có 475 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/carbon-design-system/carbon-web-components. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
carbon-design-system/carbon-web-components có những chủ đề gì?
GitHub topics của carbon-design-system/carbon-web-components: "carbon-design-system", "community", "component-library", "design-system", "hacktoberfest", "ibm", "web-components". TopGit xếp repo vào nhóm UI / UX.
carbon-design-system/carbon-web-components còn đang phát triển không?
Commit gần nhất trên carbon-design-system/carbon-web-components là 3.7 năm trước (theo timestamp GitHub). Repo có 84 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
carbon-design-system/carbon-web-components là gì?
carbon-design-system/carbon-web-components (carbon-design-system/carbon-web-components) là dự án TypeScript trên GitHub. Theo mô tả gốc: Carbon Design System variant on top of Web Components
carbon-design-system/carbon-web-components so với các dự án UI / UX khác thế nào?
carbon-design-system/carbon-web-components được TopGit xếp vào nhóm UI / UX, với 475 sao GitHub và viết bằng TypeScript. Xem trang chủ đề UI / UX trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
carbon-design-system/carbon-web-components viết bằng ngôn ngữ gì?
carbon-design-system/carbon-web-components chủ yếu viết bằng TypeScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao carbon-design-system/carbon-web-components được xếp vào nhóm UI / UX?
TopGit xếp carbon-design-system/carbon-web-components vào nhóm UI / UX dựa trên GitHub topics và mô tả của repo (gắn thẻ: "carbon-design-system", "community", "component-library"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
carbon-web-components có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về carbon-web-components.