diff --git a/.yarn/cache/@carbon-styles-npm-1.49.0-deec63f77b-7f44cd8fb4.zip b/.yarn/cache/@carbon-styles-npm-1.49.0-deec63f77b-7f44cd8fb4.zip deleted file mode 100644 index bdfd83e2350..00000000000 Binary files a/.yarn/cache/@carbon-styles-npm-1.49.0-deec63f77b-7f44cd8fb4.zip and /dev/null differ diff --git a/.yarn/cache/@carbon-themes-npm-11.30.0-a7ac8caa0a-e22b61ba56.zip b/.yarn/cache/@carbon-themes-npm-11.30.0-a7ac8caa0a-e22b61ba56.zip deleted file mode 100644 index 0c0064f1426..00000000000 Binary files a/.yarn/cache/@carbon-themes-npm-11.30.0-a7ac8caa0a-e22b61ba56.zip and /dev/null differ diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.babelrc b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.babelrc new file mode 100644 index 00000000000..74450eed94b --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.babelrc @@ -0,0 +1,22 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "modules": false, + "targets": [ + "last 1 version", + "Firefox ESR", + "not opera > 0", + "not op_mini > 0", + "not op_mob > 0", + "not android > 0", + "not edge > 0", + "not ie > 0", + "not ie_mob > 0" + ] + } + ] + ], + "plugins": [["@babel/plugin-transform-runtime", { "version": "7.3.0" }]] +} diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.gitignore b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.gitignore new file mode 100644 index 00000000000..d94d6e13e94 --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.gitignore @@ -0,0 +1,22 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.cache +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.sassrc b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.sassrc new file mode 100644 index 00000000000..956b9e0a3d8 --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/.sassrc @@ -0,0 +1,6 @@ +{ + "includePaths": [ + "node_modules", + "../../node_modules" + ] +} \ No newline at end of file diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/cdn.html b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/cdn.html new file mode 100644 index 00000000000..e26909ed64d --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/cdn.html @@ -0,0 +1,31 @@ + + + + + @carbon/ibmdotcom-web-components example + + + + + + + + + + Chat button + + + diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/index.html b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/index.html new file mode 100644 index 00000000000..6d2054b6405 --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/index.html @@ -0,0 +1,31 @@ + + + + + carbon-web-components example + + + + + + + + + + Chat button + + + diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/package.json b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/package.json new file mode 100644 index 00000000000..019a21410dd --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/package.json @@ -0,0 +1,23 @@ +{ + "name": "carbon-web-components-chat-button-example", + "version": "0.1.0", + "private": true, + "description": "Sample project for getting started with the Web Components from Carbon.", + "license": "Apache-2", + "main": "index.html", + "scripts": { + "build": "parcel build *.html --no-minify --public-url ./", + "clean": "rimraf node_modules dist .cache", + "start": "parcel index.html --port=9000 --no-hmr" + }, + "dependencies": { + "@carbon/styles": "^1.34.0", + "@carbon/web-components": "latest", + "sass": "^1.64.1" + }, + "devDependencies": { + "@babel/core": "^7.0.0-0", + "parcel-bundler": "1.12.3", + "rimraf": "^3.0.2" + } +} diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/sandbox.config.json b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/sandbox.config.json new file mode 100644 index 00000000000..a4df8557d7b --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/sandbox.config.json @@ -0,0 +1,3 @@ +{ + "template": "node" +} diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/src/index.js b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/src/index.js new file mode 100644 index 00000000000..3720c0adf1c --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/src/index.js @@ -0,0 +1,10 @@ +/** + * @license + * + * Copyright IBM Corp. 2020, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import '@carbon/web-components/es/components/chat-button/index.js'; diff --git a/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/src/styles.scss b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/src/styles.scss new file mode 100644 index 00000000000..0adba98beda --- /dev/null +++ b/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button/src/styles.scss @@ -0,0 +1,22 @@ +/** + * @license + * + * Copyright IBM Corp. 2020, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +@use '@carbon/styles/scss/reset'; +@use '@carbon/styles/scss/theme'; +@use '@carbon/styles/scss/themes'; + +@use '@carbon/styles/scss/components/button/tokens' as button-tokens; +@include theme.add-component-tokens(button-tokens.$button-tokens); + + +:root { + @include theme.theme(themes.$white); + background-color: var(--cds-background); + color: var(--cds-text-primary); +} diff --git a/packages/carbon-web-components/package.json b/packages/carbon-web-components/package.json index 1b60a60f69c..c2563df7811 100644 --- a/packages/carbon-web-components/package.json +++ b/packages/carbon-web-components/package.json @@ -69,7 +69,7 @@ "dependencies": { "@babel/runtime": "^7.16.3", "@carbon/ibm-products-styles": "2.20.1", - "@carbon/styles": "1.49.0", + "@carbon/styles": "1.50.0", "flatpickr": "4.6.1", "lit": "^2.7.6", "lodash-es": "^4.17.21" diff --git a/packages/carbon-web-components/src/components/button/button.scss b/packages/carbon-web-components/src/components/button/button.scss index 22005322b98..bc8116d0347 100644 --- a/packages/carbon-web-components/src/components/button/button.scss +++ b/packages/carbon-web-components/src/components/button/button.scss @@ -15,6 +15,7 @@ $css--plex: true !default; @use '@carbon/styles/scss/components/popover/index'; @use '@carbon/styles/scss/components/code-snippet/code-snippet' as *; @use '@carbon/styles/scss/components/tooltip'; +@use '@carbon/styles/scss/components/chat-button' as *; @use '@carbon/styles/scss/layout' as *; @include code-snippet; diff --git a/packages/carbon-web-components/src/components/chat-button/chat-button-skeleton.ts b/packages/carbon-web-components/src/components/chat-button/chat-button-skeleton.ts new file mode 100644 index 00000000000..a3999996e12 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/chat-button-skeleton.ts @@ -0,0 +1,46 @@ +/** + * @license + * + * Copyright IBM Corp. 2019, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { classMap } from 'lit/directives/class-map.js'; +import { LitElement, html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { prefix } from '../../globals/settings'; +import { CHAT_BUTTON_SIZE } from './defs'; +import styles from './chat-button.scss'; +import { carbonElement as customElement } from '../../globals/decorators/carbon-element'; + +export { CHAT_BUTTON_SIZE }; +/** + * Chat button skeleton. + * + * @element cds-chat-button-skeleton + */ +@customElement(`${prefix}-chat-button-skeleton`) +class CDSChatButtonSkeleton extends LitElement { + /** + * Specify the size of the `ChatButtonSkeleton`, from the following list of sizes: 'sm', 'md', 'lg' + */ + @property({ reflect: true }) + size = CHAT_BUTTON_SIZE.LARGE; + + render() { + const skeletonClasses = classMap({ + [`${prefix}--skeleton`]: true, + [`${prefix}--btn`]: true, + [`${prefix}--chat-btn`]: true, + [`${prefix}--layout--size-${this.size}`]: this.size, + }); + + return html`
`; + } + + static styles = styles; +} + +export default CDSChatButtonSkeleton; diff --git a/packages/carbon-web-components/src/components/chat-button/chat-button-story.mdx b/packages/carbon-web-components/src/components/chat-button/chat-button-story.mdx new file mode 100644 index 00000000000..8bf6f5fa9e7 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/chat-button-story.mdx @@ -0,0 +1,39 @@ +import { Props, Description } from '@storybook/addon-docs/blocks'; +import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn'; + +# Chat Button + +> 💡 Check our +> [CodeSandbox](https://codesandbox.io/s/github/carbon-design-system/carbon-for-ibm-dotcom/tree/main/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button) +> example implementation. + +[![Edit carbon-web-components](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/carbon-design-system/carbon-for-ibm-dotcom/tree/main/packages/carbon-web-components/examples/codesandbox/basic/components/chat-button) + +## Getting started + +Here's a quick example to get you started. + +### JS (via import) + +```javascript +import '@carbon/web-components/es/components/chat-button/index.js'; +``` + + + + +```javascript +import '@carbon/web-components/es/components/chat-button/index.js'; +import Add16 from '@carbon/web-components/es/icons/add/16'; + +function App() { + return html` + Primary ${Add16({ slot: 'icon' })} + `; +} +``` + +## `` attributes and properties + + +```` diff --git a/packages/carbon-web-components/src/components/chat-button/chat-button-story.scss b/packages/carbon-web-components/src/components/chat-button/chat-button-story.scss new file mode 100644 index 00000000000..8a898b942f5 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/chat-button-story.scss @@ -0,0 +1,15 @@ +// +// Copyright IBM Corp. 2019, 2024 +// +// This source code is licensed under the Apache-2.0 license found in the +// LICENSE file in the root directory of this source tree. +// +div[class*='test-button-'] { + margin-block-end: 4rem; + + /* stylelint-disable */ + & > * { + margin-inline-end: 2rem; + } + /* stylelint-enable */ +} diff --git a/packages/carbon-web-components/src/components/chat-button/chat-button-story.ts b/packages/carbon-web-components/src/components/chat-button/chat-button-story.ts new file mode 100644 index 00000000000..66e6fec81f3 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/chat-button-story.ts @@ -0,0 +1,87 @@ +/** + * @license + * + * Copyright IBM Corp. 2019, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { html } from 'lit'; +import './index'; +import storyDocs from './chat-button-story.mdx'; +import Add16 from '@carbon/icons/lib/add/16'; +import styles from './chat-button-story.scss'; + +export const Default = () => { + return html` + +
+
+

Sizes

+
+ + Primary ${Add16({ slot: 'icon' })} + + + Primary ${Add16({ slot: 'icon' })} + + + Primary ${Add16({ slot: 'icon' })} + +
+
+

Kinds

+
+ + Primary ${Add16({ slot: 'icon' })} + + + Secondary ${Add16({ slot: 'icon' })} + + + Tertiary ${Add16({ slot: 'icon' })} + + + Ghost ${Add16({ slot: 'icon' })} + + + Danger ${Add16({ slot: 'icon' })} + +
+
+

Quick action

+
+ + Quick action ${Add16({ slot: 'icon' })} + + + Selected and Enabled ${Add16({ slot: 'icon' })} + + + Selected and disabled ${Add16({ slot: 'icon' })} + + + Disabled ${Add16({ slot: 'icon' })} + +
+
+

Skeleton

+
+ + + +
+
+ `; +}; + +export default { + parameters: { + ...storyDocs.parameters, + }, + title: 'Experimental/Chat button', + decorators: [(story) => html` ${story()} `], +}; diff --git a/packages/carbon-web-components/src/components/chat-button/chat-button.scss b/packages/carbon-web-components/src/components/chat-button/chat-button.scss new file mode 100644 index 00000000000..88fc44d68cf --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/chat-button.scss @@ -0,0 +1,16 @@ +// +// Copyright IBM Corp. 2019, 2024 +// +// This source code is licensed under the Apache-2.0 license found in the +// LICENSE file in the root directory of this source tree. +// + +$css--plex: true !default; + +@use '@carbon/styles/scss/config' as *; +@use '@carbon/styles/scss/layout' as *; +@use '../button/button'; + +:host(#{$prefix}-chat-button-skeleton) { + @include emit-layout-tokens(); +} diff --git a/packages/carbon-web-components/src/components/chat-button/chat-button.ts b/packages/carbon-web-components/src/components/chat-button/chat-button.ts new file mode 100644 index 00000000000..76d4fec2170 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/chat-button.ts @@ -0,0 +1,92 @@ +/** + * @license + * + * Copyright IBM Corp. 2019, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { html, LitElement } from 'lit'; +import { property, customElement } from 'lit/decorators.js'; +import { prefix } from '../../globals/settings'; +import '../button/button'; +import { CHAT_BUTTON_SIZE, CHAT_BUTTON_KIND } from './defs'; +import styles from './chat-button.scss'; + +export { CHAT_BUTTON_SIZE, CHAT_BUTTON_KIND }; + +/** + * Icon Button + * + */ +@customElement(`${prefix}-chat-button`) +class CDSChatButton extends LitElement { + /** + * `true` if the button should be disabled. + */ + @property({ type: Boolean, reflect: true }) + disabled = false; + + /** + * Specify whether the `ChatButton` should be disabled + */ + @property({ reflect: true }) + kind = CHAT_BUTTON_KIND.PRIMARY; + + /** + * Chat button size. + */ + @property({ reflect: true }) + size = CHAT_BUTTON_SIZE.LARGE; + + /** + * Specify whether the `ChatButton` should be rendered as a quick action button + */ + @property({ attribute: 'is-quick-action', type: Boolean }) + isQuickAction = false; + + /** + * Specify whether the quick action `ChatButton` should be rendered as selected. This disables the input + */ + @property({ attribute: 'is-selected', type: Boolean }) + isSelected = false; + + render() { + const allowedSizes = [ + CHAT_BUTTON_SIZE.SMALL, + CHAT_BUTTON_SIZE.MEDIUM, + CHAT_BUTTON_SIZE.LARGE, + ]; + + if (this.isQuickAction) { + this.kind = CHAT_BUTTON_KIND.GHOST; + this.size = CHAT_BUTTON_SIZE.SMALL; + } else { + // Do not allow size larger than `lg` + this.size = allowedSizes.includes(this.size) + ? this.size + : CHAT_BUTTON_SIZE.LARGE; + } + + let classes = `${prefix}--chat-btn`; + classes += this.isQuickAction ? ` ${prefix}--chat-btn--quick-action` : ''; + classes += this.isSelected + ? ` ${prefix}--chat-btn--quick-action--selected` + : ''; + + return html` + + + + `; + } + + static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader +} + +export default CDSChatButton; diff --git a/packages/carbon-web-components/src/components/chat-button/defs.ts b/packages/carbon-web-components/src/components/chat-button/defs.ts new file mode 100644 index 00000000000..16df24bcf47 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/defs.ts @@ -0,0 +1,58 @@ +/** + * @license + * + * Copyright IBM Corp. 2020, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * Chat Button size. + */ +export enum CHAT_BUTTON_SIZE { + /** + * Small size. + */ + SMALL = 'sm', + + /** + * Medium size. + */ + MEDIUM = 'md', + + /** + * Large size. + */ + LARGE = 'lg', +} + +/** + * Chat button kind. + */ +export enum CHAT_BUTTON_KIND { + /** + * Primary button. + */ + PRIMARY = 'primary', + + /** + * Secondary button. + */ + SECONDARY = 'secondary', + + /** + * Tertiary button. + */ + TERTIARY = 'tertiary', + + /** + * Ghost button. + */ + GHOST = 'ghost', + + /** + * Danger button. + */ + DANGER = 'danger', +} diff --git a/packages/carbon-web-components/src/components/chat-button/index.ts b/packages/carbon-web-components/src/components/chat-button/index.ts new file mode 100644 index 00000000000..006d1c3a4b0 --- /dev/null +++ b/packages/carbon-web-components/src/components/chat-button/index.ts @@ -0,0 +1,11 @@ +/** + * @license + * + * Copyright IBM Corp. 2021, 2024 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import './chat-button'; +import './chat-button-skeleton'; diff --git a/packages/styles/package.json b/packages/styles/package.json index 485cf4137ca..95ab3d20359 100644 --- a/packages/styles/package.json +++ b/packages/styles/package.json @@ -31,7 +31,7 @@ "dependencies": { "@carbon/icons-react": "11.36.0", "@carbon/layout": "11.20.1", - "@carbon/styles": "1.49.0", + "@carbon/styles": "1.50.0", "@carbon/telemetry": "0.1.0", "@carbon/type": "11.25.1" }, diff --git a/packages/web-components/package.json b/packages/web-components/package.json index 8d1168abc9f..6b822511712 100644 --- a/packages/web-components/package.json +++ b/packages/web-components/package.json @@ -95,7 +95,7 @@ "@carbon/ibmdotcom-utilities": "2.3.0-rc.0", "@carbon/layout": "11.20.1", "@carbon/motion": "11.16.1", - "@carbon/styles": "1.49.0", + "@carbon/styles": "1.50.0", "@carbon/telemetry": "0.1.0", "@carbon/web-components": "2.3.0-rc.0", "lit": "^2.7.6", diff --git a/yarn.lock b/yarn.lock index 876919fc9cf..39fb62d2396 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3228,7 +3228,7 @@ __metadata: dependencies: "@carbon/icons-react": "npm:11.36.0" "@carbon/layout": "npm:11.20.1" - "@carbon/styles": "npm:1.49.0" + "@carbon/styles": "npm:1.50.0" "@carbon/telemetry": "npm:0.1.0" "@carbon/themes": "npm:11.31.0" "@carbon/type": "npm:11.25.1" @@ -3337,7 +3337,7 @@ __metadata: "@carbon/motion": "npm:11.16.1" "@carbon/pictograms-react": "npm:11.57.0" "@carbon/react": "npm:1.50.0" - "@carbon/styles": "npm:1.49.0" + "@carbon/styles": "npm:1.50.0" "@carbon/telemetry": "npm:0.1.0" "@carbon/type": "npm:11.25.1" "@carbon/web-components": "npm:2.3.0-rc.0" @@ -3591,28 +3591,7 @@ __metadata: languageName: unknown linkType: soft -"@carbon/styles@npm:1.49.0": - version: 1.49.0 - resolution: "@carbon/styles@npm:1.49.0" - dependencies: - "@carbon/colors": "npm:^11.20.0" - "@carbon/feature-flags": "npm:^0.16.0" - "@carbon/grid": "npm:^11.21.0" - "@carbon/layout": "npm:^11.20.0" - "@carbon/motion": "npm:^11.16.0" - "@carbon/themes": "npm:^11.30.0" - "@carbon/type": "npm:^11.25.0" - "@ibm/plex": "npm:6.0.0-next.6" - peerDependencies: - sass: ^1.33.0 - peerDependenciesMeta: - sass: - optional: true - checksum: 10/7f44cd8fb479e191e8564b986983c8ce93e5af4ac126555da9f5ca9b5c98585f40b14bbeee3a50c306fb1c72ed6169540faa2e4bad19710838178dcd2b63e605 - languageName: node - linkType: hard - -"@carbon/styles@npm:^1.50.0": +"@carbon/styles@npm:1.50.0, @carbon/styles@npm:^1.50.0": version: 1.50.0 resolution: "@carbon/styles@npm:1.50.0" dependencies: @@ -3654,18 +3633,6 @@ __metadata: languageName: node linkType: hard -"@carbon/themes@npm:^11.30.0": - version: 11.30.0 - resolution: "@carbon/themes@npm:11.30.0" - dependencies: - "@carbon/colors": "npm:^11.20.0" - "@carbon/layout": "npm:^11.20.0" - "@carbon/type": "npm:^11.25.0" - color: "npm:^4.0.0" - checksum: 10/e22b61ba5676ec136586b34fd15e297be24dbd6f3ac5d70fbe0e1e1826b00bcd6ebf80355349c9717c6ab606cefec8078697080ecf72af13c1c465732a74ee7a - languageName: node - linkType: hard - "@carbon/type@npm:11.25.1, @carbon/type@npm:^11.25.0": version: 11.25.1 resolution: "@carbon/type@npm:11.25.1" @@ -3698,7 +3665,7 @@ __metadata: "@carbon/ibm-products-styles": "npm:2.20.1" "@carbon/icon-helpers": "npm:10.46.0" "@carbon/icons": "npm:11.36.0" - "@carbon/styles": "npm:1.49.0" + "@carbon/styles": "npm:1.50.0" "@open-wc/semantic-dom-diff": "npm:~0.18.0" "@percy-io/in-percy": "npm:^0.1.11" "@percy/cli": "npm:^1.27.4"