Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): add rollup plugin to switch out .scss?lit during build #11337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions packages/carbon-web-components/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* @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.
*/

import type { StorybookConfig } from '@storybook/web-components-vite';
import { mergeConfig } from 'vite';
import { litStyleLoader, litTemplateLoader } from '@mordech/vite-lit-loader';
Expand Down
1 change: 1 addition & 0 deletions packages/carbon-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"@percy/cli": "^1.27.4",
"@percy/cypress": "^3.1.2",
"@percy/dom": "^1.27.5",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.0.3",
"@rollup/plugin-node-resolve": "^8.4.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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.
Expand All @@ -14,7 +14,7 @@ import { prefix } from '../../globals/settings';
import WarningFilled16 from '@carbon/icons/lib/warning--filled/16';
import WarningAltFilled16 from '@carbon/icons/lib/warning--alt--filled/16';
import CDSCheckbox from './checkbox';
import styles from './checkbox.scss';
import styles from './checkbox.scss?lit';
import { carbonElement as customElement } from '../../globals/decorators/carbon-element';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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.
Expand Down Expand Up @@ -53,7 +53,6 @@ const meta: Meta = {
};

export const Default = {
name: 'Default',
parameters: {
controls: { exclude: /(.*?)/ },
},
Expand All @@ -63,4 +62,4 @@ export const Playground = {
argTypes: controls,
};

export default meta;
export default meta;
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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 { LitElement, html } from 'lit';
import { customElement } from 'lit/decorators.js';
import { carbonElement as customElement } from '../../globals/decorators/carbon-element';
import { prefix } from '../../globals/settings';
import styles from './data-table.scss?lit';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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.
Expand All @@ -22,58 +22,56 @@

import storyDocs from './icon.mdx';


export const Default = {
render: () => html` ${Add16()} ${Add20()} ${Add24()} ${Add32()} `
}

render: () => html` ${Add16()} ${Add20()} ${Add24()} ${Add32()} `,
};

export const withCustomClass = {

Check warning on line 29 in packages/carbon-web-components/src/components/icon/icon.stories.ts

View workflow job for this annotation

GitHub Actions / check-packages

The story should use PascalCase notation: withCustomClass
name: 'With custom class',
render: () => html`
<style>
.test-class {
fill: #0062ff;
}
</style>
${Add16({ class: 'test-class' })} ${Add20({ class: 'test-class' })}
${Add24({ class: 'test-class' })} ${Add32({ class: 'test-class' })}
`
}
<style>
.test-class {
fill: #0062ff;
}
</style>
${Add16({ class: 'test-class' })} ${Add20({ class: 'test-class' })}
${Add24({ class: 'test-class' })} ${Add32({ class: 'test-class' })}
`,
};

export const withAriaLabel = {

Check warning on line 42 in packages/carbon-web-components/src/components/icon/icon.stories.ts

View workflow job for this annotation

GitHub Actions / check-packages

The story should use PascalCase notation: withAriaLabel
name: 'With aria label',
render: () => html`
${Add16({ 'aria-label': 'add' })} ${Add20({ 'aria-label': 'add' })}
${Add24({ 'aria-label': 'add' })} ${Add32({ 'aria-label': 'add' })}
`
}
${Add16({ 'aria-label': 'add' })} ${Add20({ 'aria-label': 'add' })}
${Add24({ 'aria-label': 'add' })} ${Add32({ 'aria-label': 'add' })}
`,
};

export const withTitle = {
export const withTitle = {

Check warning on line 50 in packages/carbon-web-components/src/components/icon/icon.stories.ts

View workflow job for this annotation

GitHub Actions / check-packages

The story should use PascalCase notation: withTitle
name: 'With title',
render: () => html`
${Add16({
'aria-describedby': 'id-title-1',
// @ts-ignore
children: svg`<title id="id-title-1">add</title>`,
})}
${Add20({
'aria-describedby': 'id-title-2',
// @ts-ignore
children: svg`<title id="id-title-2">add</title>`,
})}
${Add24({
'aria-describedby': 'id-title-3',
// @ts-ignore
children: svg`<title id="id-title-3">add</title>`,
})}
${Add32({
'aria-describedby': 'id-title-4',
// @ts-ignore
children: svg`<title id="id-title-4">add</title>`,
})}
`
}
${Add16({
'aria-describedby': 'id-title-1',
// @ts-ignore
children: svg`<title id="id-title-1">add</title>`,
})}
${Add20({
'aria-describedby': 'id-title-2',
// @ts-ignore
children: svg`<title id="id-title-2">add</title>`,
})}
${Add24({
'aria-describedby': 'id-title-3',
// @ts-ignore
children: svg`<title id="id-title-3">add</title>`,
})}
${Add32({
'aria-describedby': 'id-title-4',
// @ts-ignore
children: svg`<title id="id-title-4">add</title>`,
})}
`,
};

const meta = {
title: 'Components/Icon',
Expand All @@ -84,4 +82,4 @@
},
};

export default meta;
export default meta;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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.
Expand All @@ -19,7 +19,7 @@ const defaultArgs = {
inline: false,
size: LINK_SIZE.MEDIUM,
visited: false,
}
};

const controls = {
disabled: {
Expand All @@ -31,20 +31,20 @@ const controls = {
description: `Provide the href attribute for the <a> node`,
},
size: {
control: 'radio', options: [LINK_SIZE.SMALL, LINK_SIZE.MEDIUM, LINK_SIZE.LARGE],
description: `Specify the size of the Link. Currently supports either sm, 'md' (default) or 'lg' as an option.`
control: 'radio',
options: [LINK_SIZE.SMALL, LINK_SIZE.MEDIUM, LINK_SIZE.LARGE],
description: `Specify the size of the Link. Currently supports either sm, 'md' (default) or 'lg' as an option.`,
},
visited: {
control: 'boolean',
description: `Specify whether you want the link to receive visited styles after the link has been clicked`,
},
}
};

export const Default = {
render: () => html` <cds-link href="#"> Link </cds-link> `
render: () => html` <cds-link href="#"> Link </cds-link> `,
};


export const Inline = {
render: () => html`
<cds-link inline href="#"
Expand All @@ -64,20 +64,15 @@ export const Inline = {
Duis at tincidunt orci. Ut velit ipsum, lacinia at ex quis, aliquet
rhoncus purus. Praesent et scelerisque ligula.
</p>
`
`,
};

export const PairedWithIcon = {
args: defaultArgs,
parameters: {
controls: { exclude: /(.*?)/ },
},
render: ({
disabled,
href,
size,
onClick
}) => html`
render: ({ disabled, href, size, onClick }) => html`
<cds-link
?disabled="${disabled}"
href="${ifDefined(href)}"
Expand All @@ -91,14 +86,7 @@ export const PairedWithIcon = {
export const Playground = {
argTypes: controls,
args: defaultArgs,
render: ({
disabled,
href,
inline,
size,
visited,
onClick
}) => html`
render: ({ disabled, href, inline, size, visited, onClick }) => html`
<cds-link
?disabled="${disabled}"
href="${ifDefined(href)}"
Expand All @@ -120,4 +108,4 @@ const meta = {
},
};

export default meta;
export default meta;
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* @license
*
* Copyright IBM Corp. 2021, 2023
* 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 { prefix } from '../../globals/settings';
import CDSButton from '../button/button';
import buttonStyles from '../button/button.scss';
import buttonStyles from '../button/button.scss?lit';
import styles from './modal.scss?lit';
import { carbonElement as customElement } from '../../globals/decorators/carbon-element';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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.
Expand All @@ -15,7 +15,7 @@ import Fade16 from '@carbon/web-components/es/icons/fade/16';
import Search20 from '@carbon/web-components/es/icons/search/20';
import Notification20 from '@carbon/web-components/es/icons/notification/20';
import SwitcherIcon20 from '@carbon/web-components/es/icons/switcher/20';
import contentStyles from '@carbon/styles/scss/components/ui-shell/content/_content.scss';
import contentStyles from '@carbon/styles/scss/components/ui-shell/content/_content.scss?lit';
import { SIDE_NAV_COLLAPSE_MODE, SIDE_NAV_USAGE_MODE } from './side-nav';
import { classMap } from 'lit/directives/class-map.js';
import './index';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* 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 { render } from 'lit';
import { Default } from '../../src/components/copy-button/copy-button-story';
import { Default } from '../../src/components/copy-button/copy-button.stories';

const template = (props?) =>
Default({
Expand Down
6 changes: 3 additions & 3 deletions packages/carbon-web-components/tests/spec/link_spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2023
* 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 { render } from 'lit';
import '../../src/components/link/link';
import { pairedWithIcon } from '../../src/components/link/link.stories';
import { PairedWithIcon } from '../../src/components/link/link.stories';

Check warning on line 12 in packages/carbon-web-components/tests/spec/link_spec.ts

View workflow job for this annotation

GitHub Actions / check-packages

'PairedWithIcon' is assigned a value but never used

const template = (props?) =>
pairedWithIcon({
(PairedWithIcon = {
'cds-link': props,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2023
* 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.
Expand All @@ -10,7 +10,7 @@
import { render } from 'lit';

import CDSOverflowMenu from '../../src/components/overflow-menu/overflow-menu';
import { Playground } from '../../src/components/overflow-menu/overflow-menu-story';
import { Playground } from '../../src/components/overflow-menu/overflow-menu.stories';

const template = (props?) =>
Playground({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2022
* 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.
Expand All @@ -18,7 +18,7 @@ module.exports = function resourceJSPaths(babel) {
ImportDeclaration(path, state) {
const { node } = path;
const { value: source } = node.source;
if (/^\..*\.scss$/i.test(source)) {
if (/^\..*\.scss\?lit$/i.test(source)) {
const declaration = t.cloneNode(node);
declaration.source.value = `./${replaceExtension(source, '.css.js')}`;
path.replaceWith(declaration);
Expand Down
Loading
Loading