Skip to content

Commit

Permalink
feat(Tearsheet): Move Tearsheet into @carbon/ibm-products-web-compone…
Browse files Browse the repository at this point in the history
…nts (#6204)

* feat(Tearsheet): web components create component

* feat(Tearsheet): add test case

* feat(Tearsheet): web components wtorybook update

* feat(Tearsheet): style include issue

* feat(Tearsheet): style path update

* fix: remove sb theme package

* fix(ibm products tearsheet): theme integation issue

* fix(ibm products tearsheet): theme integation issue

* chore(storybook): rename preview.ts

* chore(storybook): rename preview.ts

* chore(storybook): update configs

* chore(styles): fix web component style import paths

* chore(deps): re-add @carbon/ibm-products-styles resolution

* chore(deps): update yarn.lock

* chore(styles): revert style import change

* chore(deps): remove styles resolution

* chore(deploy): update netlify.toml

* chore(package): update build command

* chore(package): update storybook build script

* chore(netlify): test config removal

---------

Co-authored-by: Matt Gallo <mdgallo@us.ibm.com>
Co-authored-by: kennylam <909118+kennylam@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent f7c9dd3 commit c21d102
Show file tree
Hide file tree
Showing 17 changed files with 2,269 additions and 184 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"httperror",
"httperrorother",
"importmodal",
"influencers",
"inlineedit",
"inlinetip",
"interstitialscreenview",
Expand Down
1 change: 1 addition & 0 deletions packages/core/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const globalTypes = {
defaultValue: 'g10',
toolbar: {
icon: 'paintbrush',
title: 'Theme',
items: ['white', 'g10', 'g90', 'g100'],
},
},
Expand Down
16 changes: 15 additions & 1 deletion packages/ibm-products-web-components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ import viteSVGResultCarbonIconLoader from '../tools/vite-svg-result-carbon-icon-

const config = {
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
addons: [
'@storybook/addon-links',
'@storybook/addon-toolbars',
{
name: '@storybook/addon-essentials',
options: {
actions: true,
backgrounds: false,
controls: true,
docs: true,
toolbars: true,
viewport: true,
},
},
],
framework: {
name: '@storybook/web-components-vite',
options: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { create } from '@storybook/theming';
import { create } from '@storybook/theming/create';
import packageInfo from '../package.json';

const { description, version } = packageInfo;

export default create({
base: 'light',
base: 'white',
brandTitle: `${description} v${version}`,
fontBase: "'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",
fontCode: "'IBM Plex Mono', Menlo, 'DejaVu Sans Mono', Courier, monospace",
Expand Down
9 changes: 0 additions & 9 deletions packages/ibm-products-web-components/netlify.toml

This file was deleted.

20 changes: 10 additions & 10 deletions packages/ibm-products-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"web components"
],
"scripts": {
"build": "yarn clean && node tasks/build.js && yarn wca",
"build:storybook": "yarn wca && storybook build",
"build": "node tasks/build.js && yarn wca",
"build:storybook": "storybook build",
"clean": "rimraf es lib scss dist storybook-static",
"preview": "vite preview",
"storybook": "storybook dev -p 3000",
Expand All @@ -62,14 +62,14 @@
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.0",
"@storybook/addon-essentials": "^8.2.8",
"@storybook/addon-links": "^8.2.8",
"@storybook/addon-storysource": "^8.2.8",
"@storybook/blocks": "^8.2.8",
"@storybook/manager-api": "^8.3.4",
"@storybook/theming": "^8.3.4",
"@storybook/web-components": "^8.2.8",
"@storybook/web-components-vite": "^8.2.8",
"@storybook/addon-essentials": "^8.3.6",
"@storybook/addon-links": "^8.3.6",
"@storybook/addon-storysource": "^8.3.6",
"@storybook/addon-toolbars": "^8.3.6",
"@storybook/blocks": "^8.3.6",
"@storybook/theming": "^8.3.6",
"@storybook/web-components": "^8.3.6",
"@storybook/web-components-vite": "^8.3.6",
"@types/jest": "^29.5.13",
"@vitest/browser": "latest",
"@vitest/ui": "latest",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @license
*
* Copyright IBM Corp. 2023, 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.
*/

export enum TEARSHEET_INFLUENCER_PLACEMENT {
/** right / default */
RIGHT = 'right',

/** left */
LEFT = 'left',
}

export enum TEARSHEET_INFLUENCER_WIDTH {
/** narrow /default */
NARROW = 'narrow',
/** wide */
WIDE = 'wide',
}

export enum TEARSHEET_WIDTH {
/** narrow */
NARROW = 'narrow',
/** wide */
WIDE = 'wide',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @license
*
* Copyright IBM Corp. 2024, 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 './tearsheet';
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright IBM Corp. 2023, 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/spacing' as *;
@use '@carbon/styles/scss/config' as *;

$story-prefix: 'tearsheet-stories';

@use '@carbon/styles/scss/spacing' as *;

#page-content-selector {
position: absolute;
z-index: 9999;
inset-block-start: 0;
inset-inline-start: 0;
}

.#{$story-prefix}__tabs .#{$prefix}--tab-content {
display: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { ArgTypes, Markdown, Meta } from '@storybook/blocks';
import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn';
import * as TearsheetStories from './tearsheet.stories';

<Meta of={TearsheetStories} />

# Tearsheet

> 💡 Check our
> [Stackblitz](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/tearsheet)
> example implementation.
[![Edit carbon-web-components](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/tearsheet)

Tearsheets keep users in-context of a page while performing tasks like
navigating, editing, viewing details, or configuring something new.

## Getting started

Here's a quick example to get you started.

### JS (via import)

```javascript
import '@carbon/web-components/es/components/tearsheet/index.js';
// The following are used for slotted fields
import '@carbon/web-components/es/components/text-input/index.js';
import '@carbon/web-components/es/components/textarea/index.js';
import '@carbon/web-components/es/components/button/index.js';
```

<Markdown>{`${cdnJs({ components: ['tearsheet'] })}`}</Markdown>
<Markdown>{`${cdnCss()}`}</Markdown>

### HTML

```html
<c4p-tearsheet>
<!-- Content -->
<h5>Tearsheet content</h5>
<div class="${storyPrefix}text-inputs">
<cds-text-input
label="Input A"
id="tearsheet-story-text-input-a"></cds-text-input>
<cds-text-input
label="Input B"
id="tearsheet-story-text-input-b"></cds-text-input>
</div>
<div class="${storyPrefix}text-inputs">
<cds-text-input
label="Input C"
id="tearsheet-story-text-input-c"></cds-text-input>
<cds-text-input
label="Input D"
id="tearsheet-story-text-input-d"></cds-text-input>
</div>
<div class="${storyPrefix}textarea-container">
<cds-textarea label="Notes" value="This is a text area"></cds-textarea>
<cds-textarea label="Notes" value="This is a text area"></cds-textarea>
<cds-textarea label="Notes" value="This is a text area"></cds-textarea>
</div>

<!-- subtitle optional -->
<div slot="subtitle">
Subtitle text which can provide more detail on the content being displayed.
</div>

<!-- Action toolbar optional -->
<cds-button slot="action-toolbar">Copy</cds-button>
<cds-button
slot="action-toolbar"
aria-label="Settings"
has-icon-only="true"
kind="${BUTTON_KIND.GHOST}"
size="sm"
tooltip-text="Settings">
${Settings({ slot: 'icon' })}
</cds-button>
<cds-button
slot="action-toolbar"
aria-label="Delete"
has-icon-only="true"
kind="${BUTTON_KIND.GHOST}"
size="sm"
tooltip-text="Delete">
${Trashcan({ slot: 'icon' })}
</cds-button>

<!-- Tearsheet actions optional -->
<cds-button slot="actions" kind="${BUTTON_KIND.GHOST}">Ghost</cds-button>
<cds-button slot="actions" kind="${BUTTON_KIND.PRIMARY}"></cds-button>
</c4p-tearsheet>
```

## `<c4p-tearsheet>` attributes, properties and events

Note: For `boolean` attributes, `true` means simply setting the attribute (e.g.
`<c4p-tearsheet open>`) and `false` means not setting the attribute (e.g.
`<c4p-tearsheet>` without `open` attribute).

<ArgTypes of="c4p-tearsheet" />
Loading

0 comments on commit c21d102

Please sign in to comment.