@wonderflow/react-components 11.0.7 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/basic.css +1 -1
- package/core/typography.css +1 -1
- package/core.css +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +1 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/avatar.js +3 -1
- package/dist/components/avatar/avatar.stories.js +1 -1
- package/dist/components/avatar/avatar.test.js +6 -2
- package/dist/components/button/button.module.css +1 -1
- package/dist/components/card/card.stories.d.ts.map +1 -1
- package/dist/components/card/card.stories.js +3 -8
- package/dist/components/chip/chip.js +1 -1
- package/dist/components/chip/chip.module.css +1 -1
- package/dist/components/circular-progress/circular-progress.module.css +1 -1
- package/dist/components/container/container.stories.js +1 -1
- package/dist/components/disclosure/disclosure.js +6 -6
- package/dist/components/disclosure/disclosure.module.css +1 -1
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/drawer.js +2 -2
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -2
- package/dist/components/info-state/info-state.js +2 -2
- package/dist/components/input-group/input-group.js +1 -1
- package/dist/components/linear-progress/linear-progress.d.ts.map +1 -1
- package/dist/components/linear-progress/linear-progress.js +1 -1
- package/dist/components/list/list-item.js +6 -6
- package/dist/components/list/list.module.css +1 -1
- package/dist/components/menu/menu-item/menu-item.d.ts.map +1 -1
- package/dist/components/menu/menu-item/menu-item.js +2 -2
- package/dist/components/menu/menu-item/menu-item.module.css +1 -1
- package/dist/components/menu/menu-item/menu-item.stories.js +1 -1
- package/dist/components/menu/menu.stories.js +2 -2
- package/dist/components/modal/modal.d.ts +1 -2
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +3 -3
- package/dist/components/modal/modal.stories.d.ts.map +1 -1
- package/dist/components/modal/modal.stories.js +6 -6
- package/dist/components/pagination/pagination.module.css +1 -1
- package/dist/components/popover/popover.stories.d.ts +4 -0
- package/dist/components/popover/popover.stories.d.ts.map +1 -1
- package/dist/components/popover/popover.stories.js +16 -0
- package/dist/components/select/select.d.ts +8 -0
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +2 -2
- package/dist/components/select/select.module.css +1 -1
- package/dist/components/select/select.stories.d.ts +5 -2
- package/dist/components/select/select.stories.d.ts.map +1 -1
- package/dist/components/select/select.stories.js +7 -4
- package/dist/components/select/select.test.js +1 -1
- package/dist/components/selection-controls/checkbox.d.ts.map +1 -1
- package/dist/components/selection-controls/checkbox.js +1 -1
- package/dist/components/selection-controls/radio.d.ts.map +1 -1
- package/dist/components/selection-controls/radio.js +1 -1
- package/dist/components/selection-controls/selection-controls.module.css +1 -1
- package/dist/components/selection-controls/toggle.d.ts.map +1 -1
- package/dist/components/selection-controls/toggle.js +1 -1
- package/dist/components/skeleton/skeleton.module.css +1 -1
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/snackbar/snackbar.d.ts.map +1 -1
- package/dist/components/snackbar/snackbar.js +9 -2
- package/dist/components/snackbar/snackbar.module.css +1 -1
- package/dist/components/star-meter/star-meter.js +5 -5
- package/dist/components/symbol/symbol.js +1 -1
- package/dist/components/tab/tab.module.css +1 -1
- package/dist/components/tab/tab.stories.d.ts.map +1 -1
- package/dist/components/tab/tab.stories.js +6 -0
- package/dist/components/table/table-cell/table-cell.module.css +1 -1
- package/dist/components/table/table-header/table-header.d.ts +2 -2
- package/dist/components/table/table-header/table-header.d.ts.map +1 -1
- package/dist/components/table/table-header/table-header.js +2 -2
- package/dist/components/table/table-pagination/table-pagination.js +2 -2
- package/dist/components/table/table-row/table-row.js +1 -1
- package/dist/components/table/table.js +1 -1
- package/dist/components/table/table.stories.js +2 -2
- package/dist/components/text/index.d.ts +1 -1
- package/dist/components/text/index.d.ts.map +1 -1
- package/dist/components/text/text.d.ts +42 -22
- package/dist/components/text/text.d.ts.map +1 -1
- package/dist/components/text/text.js +86 -5
- package/dist/components/text/text.module.css +1 -1
- package/dist/components/text/text.stories.d.ts +6 -1
- package/dist/components/text/text.stories.d.ts.map +1 -1
- package/dist/components/text/text.stories.js +63 -18
- package/dist/components/text/text.test.js +85 -0
- package/dist/components/textfield/base-field/base-field.module.css +1 -1
- package/dist/components/textfield/textfield.js +2 -2
- package/dist/components/textfield/textfield.module.css +1 -1
- package/dist/components/toggle-button/toggle-button.js +1 -1
- package/dist/components/tooltip/tooltip.module.css +1 -1
- package/dist/examples/shell.module.css +1 -1
- package/dist/examples/shell.stories.d.ts.map +1 -1
- package/dist/examples/shell.stories.js +2 -2
- package/dist/utils/themes.d.ts +3 -0
- package/dist/utils/themes.d.ts.map +1 -0
- package/dist/{components/prose/prose.js → utils/themes.js} +12 -6
- package/dist/utils/themes.test.d.ts +2 -0
- package/dist/utils/themes.test.d.ts.map +1 -0
- package/dist/utils/themes.test.js +26 -0
- package/package.json +3 -3
- package/dist/components/prose/index.d.ts +0 -3
- package/dist/components/prose/index.d.ts.map +0 -1
- package/dist/components/prose/index.js +0 -16
- package/dist/components/prose/prose.d.ts +0 -6
- package/dist/components/prose/prose.d.ts.map +0 -1
- package/dist/components/prose/prose.module.css +0 -1
- package/dist/components/prose/prose.stories.d.ts +0 -7
- package/dist/components/prose/prose.stories.d.ts.map +0 -1
- package/dist/components/prose/prose.stories.js +0 -12
- package/dist/components/prose/prose.test.d.ts +0 -2
- package/dist/components/prose/prose.test.d.ts.map +0 -1
- package/dist/components/prose/prose.test.js +0 -11
- package/dist/components/title/index.d.ts +0 -3
- package/dist/components/title/index.d.ts.map +0 -1
- package/dist/components/title/index.js +0 -16
- package/dist/components/title/title.d.ts +0 -40
- package/dist/components/title/title.d.ts.map +0 -1
- package/dist/components/title/title.js +0 -41
- package/dist/components/title/title.module.css +0 -1
- package/dist/components/title/title.stories.d.ts +0 -8
- package/dist/components/title/title.stories.d.ts.map +0 -1
- package/dist/components/title/title.stories.js +0 -47
- package/dist/components/title/title.test.d.ts +0 -2
- package/dist/components/title/title.test.d.ts.map +0 -1
- package/dist/components/title/title.test.js +0 -18
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getCurrentTheme, getPrefersColorScheme } from './themes';
|
|
2
|
+
describe('getCurrentTheme()', () => {
|
|
3
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
4
|
+
writable: true,
|
|
5
|
+
value: jest.fn().mockImplementation(query => ({
|
|
6
|
+
matches: false,
|
|
7
|
+
media: query,
|
|
8
|
+
onchange: null,
|
|
9
|
+
addListener: jest.fn(),
|
|
10
|
+
removeListener: jest.fn(),
|
|
11
|
+
addEventListener: jest.fn(),
|
|
12
|
+
removeEventListener: jest.fn(),
|
|
13
|
+
dispatchEvent: jest.fn(),
|
|
14
|
+
})),
|
|
15
|
+
});
|
|
16
|
+
it('should return light', () => {
|
|
17
|
+
const t = getCurrentTheme();
|
|
18
|
+
expect(t).toBe('light');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('getPrefersColorScheme()', () => {
|
|
22
|
+
it('should return a value', () => {
|
|
23
|
+
const s = getPrefersColorScheme();
|
|
24
|
+
expect(s).toBe('light');
|
|
25
|
+
});
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@types/react-dom": "17.0.14",
|
|
83
83
|
"@types/react-table": "7.7.12",
|
|
84
84
|
"@types/react-test-renderer": "18.0.0",
|
|
85
|
-
"@wonderflow/config": "
|
|
86
|
-
"@wonderflow/tokens": "
|
|
85
|
+
"@wonderflow/config": "12.0.0",
|
|
86
|
+
"@wonderflow/tokens": "12.0.0",
|
|
87
87
|
"babel-loader": "8.2.5",
|
|
88
88
|
"cpy-cli": "3.1.1",
|
|
89
89
|
"postcss": "8.4.17",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/prose/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022-2023 Wonderflow Design Team
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export { Prose } from './prose';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Polymorphic } from '../..';
|
|
2
|
-
export declare type ProseProps = Record<string, unknown>;
|
|
3
|
-
declare type PolymorphicProse = Polymorphic.ForwardRefComponent<'div', {}>;
|
|
4
|
-
export declare const Prose: PolymorphicProse;
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=prose.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prose.d.ts","sourceRoot":"","sources":["../../../src/components/prose/prose.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C,oBAAY,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAGhD,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEnE,eAAO,MAAM,KAAK,kBAaI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@layer components{.Prose>h1:is(h1,h2,h3,h4,h5,h6),.Prose>h2:is(h1,h2,h3,h4,h5,h6),.Prose>h3:is(h1,h2,h3,h4,h5,h6),.Prose>h4:is(h1,h2,h3,h4,h5,h6),.Prose>h5:is(h1,h2,h3,h4,h5,h6),.Prose>h6:is(h1,h2,h3,h4,h5,h6){margin-block-end:0}.Prose>blockquote:where(:not(:first-child)),.Prose>dd:where(:not(:first-child)),.Prose>fieldset:where(:not(:first-child)),.Prose>figure:where(:not(:first-child)),.Prose>h1:where(:not(:first-child)),.Prose>h2:where(:not(:first-child)),.Prose>h3:where(:not(:first-child)),.Prose>h4:where(:not(:first-child)),.Prose>h5:where(:not(:first-child)),.Prose>h6:where(:not(:first-child)),.Prose>hgroup:where(:not(:first-child)),.Prose>img:where(:not(:first-child)),.Prose>ol:where(:not(:first-child)),.Prose>p:where(:not(:first-child)),.Prose>picture:where(:not(:first-child)),.Prose>pre:where(:not(:first-child)),.Prose>table:where(:not(:first-child)),.Prose>ul:where(:not(:first-child)){margin-block-end:2em;margin-block-start:2em}.Prose>h1:first-child,.Prose>h2:first-child,.Prose>h3:first-child,.Prose>h4:first-child,.Prose>h5:first-child,.Prose>h6:first-child{margin-block-start:0}.Prose>h1+*,.Prose>h2+*,.Prose>h3+*,.Prose>h4+*,.Prose>h5+*,.Prose>h6+*{margin-block-start:1.3em}}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ComponentStory, Meta } from '@storybook/react';
|
|
2
|
-
import { Polymorphic } from '../..';
|
|
3
|
-
import { Prose } from './prose';
|
|
4
|
-
declare const story: Meta<Polymorphic.OwnProps<typeof Prose>>;
|
|
5
|
-
export default story;
|
|
6
|
-
export declare const Default: ComponentStory<typeof Prose>;
|
|
7
|
-
//# sourceMappingURL=prose.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prose.stories.d.ts","sourceRoot":"","sources":["../../../src/components/prose/prose.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EACM,WAAW,EAEvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAMnD,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,KAAK,CAiDhD,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Container, Separator, Text, Title, } from '../..';
|
|
3
|
-
import { Prose } from './prose';
|
|
4
|
-
const story = {
|
|
5
|
-
title: 'Typography/Prose',
|
|
6
|
-
component: Prose,
|
|
7
|
-
args: {
|
|
8
|
-
as: 'section',
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
export default story;
|
|
12
|
-
export const Default = args => (_jsx(Container, { dimension: "medium", children: _jsxs(Prose, { ...args, children: [_jsx(Title, { as: "h1", level: "display", children: "Title" }), _jsx(Text, { size: 28, children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium." }), _jsx(Title, { as: "h2", level: "2", children: "Sample H2 Title" }), _jsx("img", { style: { width: '100%' }, alt: "", src: "https://images.unsplash.com/photo-1593963171957-d87a6279226d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Separator, {}), _jsx(Title, { as: "h2", level: "2", children: "Sample H2 Title" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx("img", { style: { width: '100%' }, alt: "", src: "https://images.unsplash.com/photo-1593963171957-d87a6279226d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Title, { as: "h3", level: "3", children: "Sample H3 Title" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Title, { as: "h4", level: "4", children: "Sample H4 Title" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" })] }) }));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prose.test.d.ts","sourceRoot":"","sources":["../../../src/components/prose/prose.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable max-len */
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
import { Prose } from './prose';
|
|
5
|
-
const innerText = 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Ullam hic illo quam ipsa. Aspernatur, eveniet? Optio dolore minima magni culpa necessitatibus facilis quam libero nam.';
|
|
6
|
-
describe('<Prose>', () => {
|
|
7
|
-
test(' it should render properly', () => {
|
|
8
|
-
const { container } = render(_jsx(Prose, { children: innerText }));
|
|
9
|
-
expect(container).not.toBeNull();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/title/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022-2023 Wonderflow Design Team
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export { Title } from './title';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Polymorphic } from '../..';
|
|
2
|
-
export declare type TitleProps = {
|
|
3
|
-
/**
|
|
4
|
-
* Set the level of the title. This property only
|
|
5
|
-
* affects the visual appearance of the title and not the
|
|
6
|
-
* semantic meaning of the title, which you can define
|
|
7
|
-
* by using the `as` property.
|
|
8
|
-
*/
|
|
9
|
-
level?: '1' | '2' | '3' | '4' | '5' | '6' | 'display';
|
|
10
|
-
/**
|
|
11
|
-
* Set the text line-height of the title. This uses
|
|
12
|
-
* the predefined tokens from the typography system.
|
|
13
|
-
*/
|
|
14
|
-
lineHeight?: 'none' | 'small' | 'large';
|
|
15
|
-
/**
|
|
16
|
-
* Set the text alignment of the title based on the text direction.
|
|
17
|
-
*/
|
|
18
|
-
textAlign?: 'start' | 'center' | 'end';
|
|
19
|
-
/**
|
|
20
|
-
* Set the maximum width of the text after which it will wrap.
|
|
21
|
-
*/
|
|
22
|
-
maxWidth?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Enable or disable the responsiveness of the text. If disabled,
|
|
25
|
-
* the text will be always the same size across all breakpoints.
|
|
26
|
-
*/
|
|
27
|
-
responsive?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Auto generate anchor link inside the heading. This should be
|
|
30
|
-
* used only when the title define a new content section and has
|
|
31
|
-
* a semantic tag.
|
|
32
|
-
*
|
|
33
|
-
* @default: `false`
|
|
34
|
-
*/
|
|
35
|
-
anchor?: boolean;
|
|
36
|
-
};
|
|
37
|
-
declare type PolymorphicTitle = Polymorphic.ForwardRefComponent<'span', TitleProps>;
|
|
38
|
-
export declare const Title: PolymorphicTitle;
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=title.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../../src/components/title/title.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAAE,WAAW,EAAU,MAAM,cAAc,CAAC;AAInD,oBAAY,UAAU,GAAG;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACtD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACxC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAA;AAED,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE5E,eAAO,MAAM,KAAK,kBAqDI,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022-2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import clsx from 'clsx';
|
|
18
|
-
import { Children, forwardRef, useCallback, } from 'react';
|
|
19
|
-
import slugify from 'slugify';
|
|
20
|
-
import { Symbol } from '../..';
|
|
21
|
-
import * as styles from './title.module.css';
|
|
22
|
-
export const Title = forwardRef(({ children, className, as: Wrapper = 'span', lineHeight = 'small', level = '1', textAlign = 'start', maxWidth, responsive = true, style, anchor, id, ...otherProps }, forwardedRef) => {
|
|
23
|
-
const computedLevel = level.match(/\d/g) ? `H${level}` : `${level.charAt(0).toUpperCase()}${level.slice(1)}`;
|
|
24
|
-
const getTextFromChildren = useCallback(() => {
|
|
25
|
-
let label = '';
|
|
26
|
-
Children.map(children, (child) => {
|
|
27
|
-
if (typeof child === 'string') {
|
|
28
|
-
label += child;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return label;
|
|
32
|
-
}, [children]);
|
|
33
|
-
const generatedID = slugify(String(id ?? getTextFromChildren()), { lower: true });
|
|
34
|
-
const dynamicStyle = {
|
|
35
|
-
'--max-w': maxWidth,
|
|
36
|
-
'--t-align': textAlign,
|
|
37
|
-
};
|
|
38
|
-
return (_jsxs(Wrapper, { ref: forwardedRef, "data-title-line-height": lineHeight, "data-title-responsive": responsive,
|
|
39
|
-
// @ts-expect-error: computedLevel is not a pure class in css module
|
|
40
|
-
className: clsx(styles.Title, styles[computedLevel], className), style: { ...dynamicStyle, ...style }, id: generatedID, ...otherProps, children: [children, anchor && (_jsx("a", { href: `#${generatedID}`, className: styles.Anchor, children: _jsx(Symbol, { source: "link", weight: "duotone", dimension: 24 }) }))] }));
|
|
41
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@layer components{.Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.5;color:var(--heading-foreground,var(--dimmed-9));display:block;font-size:var(--fs-max);line-height:1.2;max-inline-size:var(--max-w,initial);min-block-size:.01vh;overflow-wrap:break-word;text-align:var(--t-align)}.Title[data-title-line-height=small]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.2}.Title[data-title-line-height=large]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){line-height:1.5}.Title:is(.H6){--fs-min:0.875rem;--fs-max:1.125rem;font-weight:700}.Title:is(.H5){--fs-min:1rem;--fs-max:1.33rem;font-weight:700}.Title:is(.H5):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H4){--fs-min:1.33rem;--fs-max:1.77rem;font-weight:700}.Title:is(.H4):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H3){--fs-min:1.77rem;--fs-max:2.37rem;font-weight:800}.Title:is(.H3):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H2){--fs-min:2.37rem;--fs-max:3.16rem;font-weight:800}.Title:is(.H2):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H1){--fs-min:3.16rem;--fs-max:4.2rem;font-weight:800}.Title:is(.H1):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title.Display{--fs-min:4.2rem;--fs-max:5.6rem;font-weight:800}.Title.Display:before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title[data-title-responsive=true]{font-size:var(--fs-min)}@media (min-width:48em){.Title[data-title-responsive=true]{font-size:var(--fs-max)}}}@layer overrides{.Anchor{align-items:center;background-color:var(--highlight-cyan-background);background-image:none;block-size:max(16px,.6em);border-radius:.5rem;color:var(--heading-foreground,var(--dimmed-9));display:inline-flex;inline-size:max(16px,.6em);justify-content:center;line-height:1;margin-left:.2em;padding:.1em;visibility:hidden}.Title:focus-within .Anchor,.Title:hover .Anchor{visibility:visible}.Anchor svg{height:100%;width:100%}}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
-
import { Title } from './title';
|
|
3
|
-
declare const story: ComponentMeta<typeof Title>;
|
|
4
|
-
export default story;
|
|
5
|
-
export declare const Default: ComponentStory<typeof Title>;
|
|
6
|
-
export declare const Single: ComponentStory<import("../../types/polymorphic").ForwardRefComponent<"span", import("./title").TitleProps>>;
|
|
7
|
-
export declare const WithAnchor: ComponentStory<import("../../types/polymorphic").ForwardRefComponent<"span", import("./title").TitleProps>>;
|
|
8
|
-
//# sourceMappingURL=title.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"title.stories.d.ts","sourceRoot":"","sources":["../../../src/components/title/title.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAuBtC,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,KAAK,CAUhD,CAAC;AAQF,eAAO,MAAM,MAAM,6GAAoB,CAAC;AAQxC,eAAO,MAAM,UAAU,6GAAoB,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Container } from '../..';
|
|
3
|
-
import { Title } from './title';
|
|
4
|
-
const story = {
|
|
5
|
-
title: 'Typography/Title',
|
|
6
|
-
component: Title,
|
|
7
|
-
parameters: {
|
|
8
|
-
controls: { hideNoControlsWarning: true },
|
|
9
|
-
},
|
|
10
|
-
args: {
|
|
11
|
-
responsive: true,
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
level: {
|
|
15
|
-
options: ['display', '1', '2', '3', '4', '5', '6'],
|
|
16
|
-
control: { type: 'select' },
|
|
17
|
-
},
|
|
18
|
-
lineHeight: {
|
|
19
|
-
options: ['none', 'small', 'large'],
|
|
20
|
-
control: { type: 'inline-radio' },
|
|
21
|
-
},
|
|
22
|
-
textAlign: {
|
|
23
|
-
options: ['start', 'center', 'end'],
|
|
24
|
-
control: { type: 'inline-radio' },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
export default story;
|
|
29
|
-
export const Default = ({ lineHeight }) => (_jsxs(Container, { children: [_jsx(Title, { lineHeight: lineHeight, as: "h1", level: "display", children: "Sample title" }), _jsx(Title, { lineHeight: lineHeight, as: "h1", level: "1", children: "Sample title" }), _jsx(Title, { lineHeight: lineHeight, as: "h2", level: "2", children: "Sample title" }), _jsx(Title, { lineHeight: lineHeight, as: "h3", level: "3", children: "Sample title" }), _jsx(Title, { lineHeight: lineHeight, as: "h4", level: "4", children: "Sample title" }), _jsx(Title, { lineHeight: lineHeight, as: "h5", level: "5", children: "Sample title" }), _jsx(Title, { lineHeight: lineHeight, as: "h6", level: "6", children: "Sample title" })] }));
|
|
30
|
-
const Template = args => (_jsx(Container, { dimension: "medium", children: _jsx(Title, { ...args, children: "Sample title" }) }));
|
|
31
|
-
export const Single = Template.bind({});
|
|
32
|
-
Single.args = {
|
|
33
|
-
as: 'span',
|
|
34
|
-
lineHeight: 'small',
|
|
35
|
-
level: '1',
|
|
36
|
-
maxWidth: 'auto',
|
|
37
|
-
textAlign: 'center',
|
|
38
|
-
};
|
|
39
|
-
export const WithAnchor = Template.bind({});
|
|
40
|
-
WithAnchor.args = {
|
|
41
|
-
as: 'span',
|
|
42
|
-
lineHeight: 'small',
|
|
43
|
-
level: '1',
|
|
44
|
-
maxWidth: 'auto',
|
|
45
|
-
textAlign: 'center',
|
|
46
|
-
anchor: true,
|
|
47
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"title.test.d.ts","sourceRoot":"","sources":["../../../src/components/title/title.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { Text } from '../text';
|
|
4
|
-
import { Title } from './title';
|
|
5
|
-
describe('<Title>', () => {
|
|
6
|
-
test(' it should render properly', () => {
|
|
7
|
-
const { container } = render(_jsx(Title, { children: "Some title text" }));
|
|
8
|
-
expect(container).not.toBeNull();
|
|
9
|
-
});
|
|
10
|
-
test(' it should render properly with props', () => {
|
|
11
|
-
const { container } = render(_jsx(Title, { level: "display", anchor: true, children: "Some title text level 3" }));
|
|
12
|
-
expect(container).not.toBeNull();
|
|
13
|
-
});
|
|
14
|
-
test(' it should render properly with props', () => {
|
|
15
|
-
const { container } = render(_jsx(Title, { level: "display", anchor: true, children: _jsx(Text, { children: "Some text" }) }));
|
|
16
|
-
expect(container).not.toBeNull();
|
|
17
|
-
});
|
|
18
|
-
});
|