Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import type { Decorator, StoryFn } from '@storybook/react-webpack5';
import { FASTElement, customElement, html, attr } from '@microsoft/fast-element';
import { teamsLightTheme, teamsDarkTheme, webLightTheme, webDarkTheme } from '@fluentui/tokens';
import { setThemeFor } from '@fluentui/web-components';
import { setTheme } from '@fluentui/web-components';

const themes = [
{ id: 'web-light', label: 'Web Light', theme: webLightTheme },
Expand Down Expand Up @@ -36,7 +36,7 @@ export class FASTThemeDecorator extends FASTElement {
connectedCallback() {
super.connectedCallback();
const theme = themes.find(value => value.id === this.fluentTheme)?.theme ?? defaultTheme.theme;
setThemeFor(this, theme);
setTheme(theme);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: migrate to esbuild for CDN bundle, enable setTheme on globalThis",
"packageName": "@fluentui/web-components",
"email": "13071055+chrisdholt@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const useStyles = makeStyles({
description: { margin: '0 0 12px' },

card: {
width: '400px',
maxWidth: '100%',
maxWidth: '400px',
width: '100%',
height: 'fit-content',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const useStyles = makeStyles({
description: { margin: '0 0 12px' },

card: {
width: '480px',
maxWidth: '100%',
maxWidth: '480px',
width: '100%',
height: 'fit-content',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const resolveAsset = (asset: string) => {
const useStyles = makeStyles({
card: {
margin: 'auto',
width: '720px',
maxWidth: '100%',
maxWidth: '720px',
width: '100%',
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const useStyles = makeStyles({
gap: '16px',
},
card: {
width: '400px',
maxWidth: '100%',
maxWidth: '400px',
minWidth: '230px',
width: '100%',
},
});

Expand Down Expand Up @@ -60,7 +61,7 @@ export const Disabled = (): JSXElement => {
<div className={styles.container}>
<div>
<h3>Default Card</h3>
<div style={{ display: 'flex', gap: '16px' }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px' }}>
<Card className={styles.card}>
<CardContentExample />
</Card>
Expand All @@ -73,7 +74,7 @@ export const Disabled = (): JSXElement => {

<div>
<h3>Interactive Card</h3>
<div style={{ display: 'flex', gap: '16px' }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px' }}>
<Card className={styles.card} onClick={() => alert('Card clicked')}>
<CardContentExample />
</Card>
Expand All @@ -87,7 +88,7 @@ export const Disabled = (): JSXElement => {
<div>
<h3>Selectable Card</h3>
<div style={{ display: 'flex', flexDirection: 'column', rowGap: '16px' }}>
<div style={{ display: 'flex', gap: '16px' }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px' }}>
<Card
className={styles.card}
selected={isSelected1}
Expand All @@ -100,7 +101,7 @@ export const Disabled = (): JSXElement => {
</Card>
</div>

<div style={{ display: 'flex', gap: '16px' }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px' }}>
<Card
className={styles.card}
selected={isSelected2}
Expand All @@ -118,7 +119,7 @@ export const Disabled = (): JSXElement => {

<div>
<h3>Outline Card</h3>
<div style={{ display: 'flex', gap: '16px' }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px' }}>
<Card className={styles.card} appearance="outline">
<CardContentExample />
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const useStyles = makeStyles({
description: { margin: '0 0 12px' },

card: {
width: '400px',
maxWidth: '100%',
maxWidth: '400px',
width: '100%',
height: 'fit-content',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const useStyles = makeStyles({
},

card: {
width: '360px',
maxWidth: '100%',
width: '100%',
height: 'fit-content',
},

section: {
width: 'fit-content',
maxWidth: '360px',
width: '100%',
},

title: { margin: '0 0 12px' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const useStyles = makeStyles({
},

card: {
width: '400px',
maxWidth: '100%',
maxWidth: '400px',
width: '100%',
height: 'fit-content',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const useStyles = makeStyles({
},

card: {
width: '400px',
maxWidth: '100%',
maxWidth: '400px',
width: '100%',
height: 'fit-content',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const useStyles = makeStyles({
title: { margin: '0 0 12px' },

card: {
width: '300px',
maxWidth: '100%',
maxWidth: '300px',
width: '100%',
height: 'fit-content',
},

Expand Down Expand Up @@ -112,8 +112,9 @@ export const Size = (): JSXElement => {
Size.parameters = {
docs: {
description: {
story: `Size options are mainly to provide variety, and consistency when using cards for different usages. It
relates to padding and border-radius and not so much the actual dimensions of the card.`,
story:
'Size options are mainly to provide variety, and consistency when using cards for different usages.' +
'It relates to padding and border-radius and not so much the actual dimensions of the card.',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const useStyles = makeStyles({
},

card: {
width: '280px',
maxWidth: '280px',
width: '100%',
height: 'fit-content',
},

Expand Down Expand Up @@ -57,6 +58,7 @@ const useStyles = makeStyles({
gap: '16px',
display: 'flex',
flexDirection: 'column',
width: '100%',
},
});

Expand Down
10 changes: 6 additions & 4 deletions packages/web-components/.storybook/preview.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { teamsDarkTheme, teamsLightTheme, webDarkTheme, webLightTheme } from '@fluentui/tokens';
import * as prettier from 'prettier';
import prettierPluginHTML from 'prettier/parser-html.js';
import { setTheme } from '../src/theme/set-theme.js';
import webcomponentsTheme from './theme.mjs';

import '../src/index-rollup.js';
Expand All @@ -17,9 +16,11 @@ const themes = {
};

// This is needed in Playwright.
Object.defineProperty(window, 'setTheme', { value: setTheme });
// @ts-ignore - setTheme is set on globalThis.Fluent by the index-rollup bundle
Object.defineProperty(window, 'Fluent', { value: globalThis.Fluent });

setTheme(themes['web-light']);
// @ts-ignore - setTheme is set on globalThis.Fluent by the index-rollup bundle
Fluent.setTheme(themes['web-light']);

export const globalTypes = {
theme: {
Expand Down Expand Up @@ -63,7 +64,8 @@ export const decorators = [
* @type {keyof typeof themes}
*/
const theme = context.globals.theme || 'web-light';
setTheme(themes[theme]);
// @ts-ignore - setTheme is set on globalThis.Fluent by the index-rollup bundle
Fluent.setTheme(themes[theme]);

// Set direction on the document body
const dir = context.globals.dir || 'ltr';
Expand Down
5 changes: 0 additions & 5 deletions packages/web-components/docs/web-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3586,11 +3586,6 @@ export const roleForMenuItem: {
// @public
export function setTheme(theme: Theme | null, node?: Document | HTMLElement): void;

// Warning: (ae-internal-missing-underscore) The name "setThemeFor" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal @deprecated (undocumented)
export function setThemeFor(element: HTMLElement, theme: Theme | null): void;

// @public
export const shadow16 = "var(--shadow16)";

Expand Down
19 changes: 17 additions & 2 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
],
"exports": {
".": "./dist/esm/index.js",
"./web-components.js": "./dist/web-components.js",
"./web-components.min.js": "./dist/web-components.min.js",
"./web-components-all.js": {
"types": "./dist/web-components.d.ts",
"default": "./dist/web-components-all.js"
},
"./web-components-all.min.js": {
"types": "./dist/web-components.d.ts",
"default": "./dist/web-components-all.min.js"
},
"./utils/behaviors/*.js": "./dist/esm/utils/behaviors/*.js",
"./utils/*.js": "./dist/esm/utils/*.js",
"./utilities.js": "./dist/esm/utils/index.js",
Expand All @@ -47,10 +57,14 @@
},
"sideEffects": [
"define.*",
"define-all.*",
"index-rollup.*",
"index-all-rollup.*",
"./dist/esm/**/define.js",
"./dist/web-components.js",
"./dist/web-components.min.js"
"./dist/web-components.min.js",
"./dist/web-components-all.js",
"./dist/web-components-all.min.js"
],
"scripts": {
"analyze": "cem analyze",
Expand Down Expand Up @@ -85,7 +99,8 @@
"@wc-toolkit/cem-inheritance": "1.2.2",
"@wc-toolkit/module-path-resolver": "1.0.0",
"@wc-toolkit/type-parser": "1.0.3",
"chromedriver": "^125.0.0"
"chromedriver": "^125.0.0",
"rollup-plugin-fast-tagged-templates": "^1.0.2"
},
"dependencies": {
"@fluentui/tokens": "1.0.0-alpha.23",
Expand Down
45 changes: 24 additions & 21 deletions packages/web-components/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonJS from 'rollup-plugin-commonjs';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import transformTaggedTemplate from 'rollup-plugin-transform-tagged-template';
import { transformCSSFragment, transformHTMLFragment } from './scripts/transform-fragments';
import fastTaggedTemplates from 'rollup-plugin-fast-tagged-templates';

const parserOptions = {
sourceType: 'module',
};
const plugins = [
nodeResolve({ browser: true }),
commonJS(),
esbuild({
tsconfig: './tsconfig.lib.json',
}),
fastTaggedTemplates(),
];

export default [
{
Expand All @@ -22,22 +26,21 @@ export default [
plugins: [minify()],
},
],
plugins: [
nodeResolve({ browser: true }),
commonJS(),
esbuild({
tsconfig: './tsconfig.lib.json',
}),
transformTaggedTemplate({
tagsToProcess: ['css'],
transformer: transformCSSFragment,
parserOptions,
}),
transformTaggedTemplate({
tagsToProcess: ['html'],
transformer: transformHTMLFragment,
parserOptions,
}),
plugins,
},
{
input: 'src/index-all-rollup.ts',
output: [
{
file: 'dist/web-components-all.js',
format: 'esm',
},
{
file: 'dist/web-components-all.min.js',
format: 'esm',
plugins: [minify()],
},
],
plugins,
},
];
29 changes: 0 additions & 29 deletions packages/web-components/scripts/transform-fragments.js

This file was deleted.

Loading
Loading