Skip to content

Commit 264bbe5

Browse files
authored
More components (#21)
* Add card * Add divider * Add radio component * Wrap new components for React * Add new components to lab demo * Add switch component * Add visual test * Add switch snapshots * Add switch to wrapped react components and demo
1 parent 98c9383 commit 264bbe5

File tree

73 files changed

+1367
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1367
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import {
5+
neutralForegroundRest,
6+
typeRampBaseFontSize
7+
} from '@microsoft/fast-components';
8+
import { setTheme } from '../utilities/storybook';
9+
10+
export default {
11+
title: 'Card',
12+
parameters: {
13+
controls: {
14+
disabled: true
15+
},
16+
actions: {
17+
disabled: true
18+
}
19+
},
20+
decorators: [
21+
story => `<style>
22+
jp-card {
23+
color: var(${neutralForegroundRest.cssCustomProperty});
24+
font-size: var(${typeRampBaseFontSize.cssCustomProperty});
25+
padding: 4px;
26+
}
27+
</style>
28+
${story()}`
29+
]
30+
};
31+
32+
const Template = (
33+
args,
34+
{ globals: { backgrounds, accent }, parameters }
35+
): string => {
36+
setTheme(accent, parameters.backgrounds, backgrounds);
37+
38+
return `<jp-card>
39+
Card with text
40+
</jp-card>`;
41+
};
42+
43+
export const Default = Template.bind({});
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { test, expect } from '@playwright/test';
5+
6+
test('Default', async ({ page }) => {
7+
await page.goto('/iframe.html?id=card--default');
8+
9+
expect(await page.locator('jp-card').screenshot()).toMatchSnapshot(
10+
'card-default.png'
11+
);
12+
});

packages/components/src/card/index.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import {
5+
Card as FoundationCard,
6+
cardTemplate as template
7+
} from '@microsoft/fast-foundation';
8+
import { Card, cardStyles as styles } from '@microsoft/fast-components';
9+
10+
/**
11+
* A function that returns a {@link @microsoft/fast-foundation#Card} registration for configuring the component with a DesignSystem.
12+
* Implements {@link @microsoft/fast-foundation#cardTemplate}
13+
*
14+
*
15+
* @public
16+
* @remarks
17+
* Generates HTML Element: `<jp-card>`
18+
*/
19+
export const jpCard = Card.compose({
20+
baseName: 'card',
21+
baseClass: FoundationCard,
22+
template,
23+
styles
24+
});
25+
26+
export { Card, styles as cardStyles };

packages/components/src/custom-elements.ts

+20
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ import { jpAvatar } from './avatar/index';
77
import { jpBreadcrumb } from './breadcrumb/index';
88
import { jpBreadcrumbItem } from './breadcrumb-item/index';
99
import { jpButton } from './button/index';
10+
import { jpCard } from './card/index';
1011
import { jpCheckbox } from './checkbox/index';
1112
import { jpCombobox } from './combobox/index';
1213
import { jpDataGrid, jpDataGridCell, jpDataGridRow } from './data-grid/index';
14+
import { jpDivider } from './divider/index';
1315
import { jpNumberField } from './number-field/index';
1416
import { jpOption } from './option/index';
1517
import { jpProgress } from './progress/index';
1618
import { jpProgressRing } from './progress-ring/index';
19+
import { jpRadio } from './radio/index';
20+
import { jpRadioGroup } from './radio-group/index';
1721
import { jpSearch } from './search/index';
1822
import { jpSelect } from './select/index';
1923
import { jpSlider } from './slider/index';
2024
import { jpSliderLabel } from './slider-label/index';
25+
import { jpSwitch } from './switch/index';
2126
import { jpTabPanel } from './tab-panel/index';
2227
import { jpTab } from './tab/index';
2328
import { jpTabs } from './tabs/index';
@@ -35,17 +40,22 @@ import type { Avatar } from './avatar/index';
3540
import type { Breadcrumb } from './breadcrumb/index';
3641
import type { BreadcrumbItem } from './breadcrumb-item/index';
3742
import type { Button } from './button/index';
43+
import type { Card } from './card/index';
3844
import type { Checkbox } from './checkbox/index';
3945
import type { Combobox } from './combobox/index';
4046
import type { DataGrid, DataGridCell, DataGridRow } from './data-grid/index';
47+
import type { Divider } from './divider/index';
4148
import type { NumberField } from './number-field/index';
4249
import type { Option } from './option/index';
4350
import type { Progress } from './progress/index';
4451
import type { ProgressRing } from './progress-ring/index';
52+
import type { Radio } from './radio/index';
53+
import type { RadioGroup } from './radio-group/index';
4554
import type { Search } from './search/index';
4655
import type { Select } from './select/index';
4756
import type { Slider } from './slider/index';
4857
import type { SliderLabel } from './slider-label/index';
58+
import type { Switch } from './switch/index';
4959
import type { TabPanel } from './tab-panel/index';
5060
import type { Tab } from './tab/index';
5161
import type { Tabs } from './tabs/index';
@@ -62,19 +72,24 @@ export {
6272
jpBreadcrumb,
6373
jpBreadcrumbItem,
6474
jpButton,
75+
jpCard,
6576
jpCheckbox,
6677
jpCombobox,
6778
jpDataGrid,
6879
jpDataGridCell,
6980
jpDataGridRow,
81+
jpDivider,
7082
jpNumberField,
7183
jpOption,
7284
jpProgress,
7385
jpProgressRing,
86+
jpRadio,
87+
jpRadioGroup,
7488
jpSearch,
7589
jpSelect,
7690
jpSlider,
7791
jpSliderLabel,
92+
jpSwitch,
7893
jpTab,
7994
jpTabPanel,
8095
jpTabs,
@@ -98,19 +113,24 @@ export const allComponents = {
98113
jpBreadcrumb,
99114
jpBreadcrumbItem,
100115
jpButton,
116+
jpCard,
101117
jpCheckbox,
102118
jpCombobox,
103119
jpDataGrid,
104120
jpDataGridCell,
105121
jpDataGridRow,
122+
jpDivider,
106123
jpNumberField,
107124
jpOption,
108125
jpProgress,
109126
jpProgressRing,
127+
jpRadio,
128+
jpRadioGroup,
110129
jpSearch,
111130
jpSelect,
112131
jpSlider,
113132
jpSliderLabel,
133+
jpSwitch,
114134
jpTab,
115135
jpTabPanel,
116136
jpTabs,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { setTheme } from '../utilities/storybook';
5+
6+
export default {
7+
title: 'Divider',
8+
argTypes: {
9+
orientation: { control: 'radio', options: ['horizontal', 'vertical'] }
10+
},
11+
parameters: {
12+
actions: {
13+
disabled: true
14+
}
15+
},
16+
decorators: [
17+
story => `
18+
<style>
19+
#container {
20+
width: 300px;
21+
height: 300px;
22+
}
23+
</style>
24+
<div id="container">
25+
${story()}
26+
</div>`
27+
]
28+
};
29+
30+
const Template = (
31+
args,
32+
{ globals: { backgrounds, accent }, parameters }
33+
): string => {
34+
setTheme(accent, parameters.backgrounds, backgrounds);
35+
36+
return `<jp-divider orientation="${args.orientation}"></jp-divider>`;
37+
};
38+
39+
export const Default = Template.bind({});
40+
Default.args = {
41+
orientation: 'horizontal'
42+
};
43+
44+
export const Vertical = Template.bind({});
45+
Vertical.args = {
46+
...Default.args,
47+
orientation: 'vertical'
48+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { test, expect } from '@playwright/test';
5+
6+
test('Default', async ({ page }) => {
7+
await page.goto('/iframe.html?id=divider--default');
8+
9+
expect(await page.locator('jp-divider').screenshot()).toMatchSnapshot(
10+
'divider-default.png'
11+
);
12+
});
13+
14+
test('Vertical', async ({ page }) => {
15+
await page.goto('/iframe.html?id=divider--vertical');
16+
17+
expect(await page.locator('jp-divider').screenshot()).toMatchSnapshot(
18+
'divider-vertical.png'
19+
);
20+
});
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {
2+
Divider,
3+
dividerTemplate as template
4+
} from '@microsoft/fast-foundation';
5+
import { dividerStyles as styles } from '@microsoft/fast-components';
6+
7+
/**
8+
* A function that returns a {@link @microsoft/fast-foundation#Divider} registration for configuring the component with a DesignSystem.
9+
* Implements {@link @microsoft/fast-foundation#dividerTemplate}
10+
*
11+
*
12+
* @public
13+
* @remarks
14+
* Generates HTML Element: `<jp-divider>`
15+
*/
16+
export const jpDivider = Divider.compose({
17+
baseName: 'divider',
18+
template,
19+
styles
20+
});
21+
22+
/**
23+
* Base class for Divider
24+
* @public
25+
*/
26+
export { Divider };
27+
28+
export { styles as dividerStyles };

packages/components/src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ export * from './avatar/index';
1313
export * from './breadcrumb/index';
1414
export * from './breadcrumb-item/index';
1515
export * from './button/index';
16+
export * from './card/index';
1617
export * from './checkbox/index';
1718
export * from './combobox/index';
1819
export * from './data-grid/index';
20+
export * from './divider/index';
1921
export * from './number-field/index';
2022
export * from './option/index';
2123
export * from './progress/index';
24+
export * from './radio/index';
25+
export * from './radio-group/index';
2226
export * from './search/index';
2327
export * from './select/index';
2428
export * from './slider-label/index';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import {
5+
RadioGroup,
6+
radioGroupTemplate as template
7+
} from '@microsoft/fast-foundation';
8+
import { radioGroupStyles as styles } from '@microsoft/fast-components';
9+
10+
/**
11+
* A function that returns a {@link @microsoft/fast-foundation#RadioGroup} registration for configuring the component with a DesignSystem.
12+
* Implements {@link @microsoft/fast-foundation#radioGroupTemplate}
13+
*
14+
*
15+
* @public
16+
* @remarks
17+
* Generates HTML Element: `<jp-radio-group>`
18+
*/
19+
export const jpRadioGroup = RadioGroup.compose({
20+
baseName: 'radio-group',
21+
template,
22+
styles
23+
});
24+
25+
/**
26+
* Base class for RadioGroup
27+
* @public
28+
*/
29+
export { RadioGroup };
30+
31+
export { styles as radioGroupStyles };

0 commit comments

Comments
 (0)