@bonniernews/dn-design-system-web 21.1.9 → 21.1.10
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/@types/components/icon-sprite/icon-sprite.d.ts +17 -0
- package/@types/components/icon-with-wrapper/icon-with-wrapper.d.ts +23 -0
- package/@types/components/pictogram/pictogram.d.ts +17 -0
- package/{preact → @types}/index.d.ts +6 -0
- package/@types/types/token-types/colors.d.ts +5 -0
- package/@types/types/token-types/icons.d.ts +2 -0
- package/CHANGELOG.md +7 -0
- package/components/icon-sprite/icon-sprite.tsx +39 -0
- package/components/icon-with-wrapper/icon-with-wrapper.tsx +53 -0
- package/components/pictogram/pictogram.tsx +37 -0
- package/components/spinner/README.md +1 -1
- package/index.d.ts +4 -0
- package/index.tsx +9 -0
- package/package.json +4 -16
- package/preact/components.cjs +234 -0
- package/preact/components.cjs.map +4 -4
- package/preact/components.esm.js +234 -0
- package/preact/components.esm.js.map +4 -4
- package/tsconfig-preact.json +5 -2
- package/types/token-types/colors.ts +7 -0
- package/types/token-types/icons.ts +3 -0
- package/react/components/divider/divider.d.ts +0 -14
- package/react/components/footer/footer.d.ts +0 -33
- package/react/components/footer/logoWithPayoff.d.ts +0 -1
- package/react/components/quote/quote.d.ts +0 -16
- package/react/components/spinner/spinner.d.ts +0 -16
- package/react/components/teaser-card/teaser-card.d.ts +0 -17
- package/react/components/teaser-onsite/teaser-onsite.d.ts +0 -23
- package/react/components/thematic-break/thematic-break.d.ts +0 -13
- package/react/components.cjs +0 -192
- package/react/components.cjs.map +0 -7
- package/react/components.esm.js +0 -169
- package/react/components.esm.js.map +0 -7
- package/react/helpers/formatClassString.d.ts +0 -1
- package/react/index.d.ts +0 -14
- package/tsconfig-react.json +0 -11
- /package/{preact → @types}/components/divider/divider.d.ts +0 -0
- /package/{preact → @types}/components/footer/footer.d.ts +0 -0
- /package/{preact → @types}/components/footer/logoWithPayoff.d.ts +0 -0
- /package/{preact → @types}/components/quote/quote.d.ts +0 -0
- /package/{preact → @types}/components/spinner/spinner.d.ts +0 -0
- /package/{preact → @types}/components/teaser-card/teaser-card.d.ts +0 -0
- /package/{preact → @types}/components/teaser-onsite/teaser-onsite.d.ts +0 -0
- /package/{preact → @types}/components/thematic-break/thematic-break.d.ts +0 -0
- /package/{preact → @types}/helpers/formatClassString.d.ts +0 -0
- /package/components/icon-sprite/{README.md → README-NJK.md} +0 -0
- /package/components/pictogram/{README.md → README-NJK.md} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface IconProps {
|
|
2
|
+
iconName: string;
|
|
3
|
+
classNames?: string;
|
|
4
|
+
attributes?: object;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-sprite)
|
|
8
|
+
* - Storybook: [icon](https://designsystem.dn.se/?path=/docs/foundations-icons--docs)
|
|
9
|
+
*
|
|
10
|
+
* The IconUse component is used to render a specific icon from the sprite, but mostly we will use the IconWithWrapper component.
|
|
11
|
+
* The IconSprite component is only used to export the sprite file.
|
|
12
|
+
*
|
|
13
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
14
|
+
* `@use '@bonniernews/dn-design-system-web/components/icon/icon.scss'`
|
|
15
|
+
*/
|
|
16
|
+
export declare const IconUse: ({ iconName, classNames, attributes }: IconProps) => import("preact").JSX.Element;
|
|
17
|
+
export declare const IconSprite: () => import("preact").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IconColors } from '../../types/token-types/colors';
|
|
2
|
+
import { Icons } from '../../types/token-types/icons';
|
|
3
|
+
export interface IconProps {
|
|
4
|
+
iconName: Icons;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: IconColors;
|
|
7
|
+
classNames?: string;
|
|
8
|
+
attributes?: object;
|
|
9
|
+
forcePx?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-sprite)
|
|
13
|
+
* - Storybook: [icon](https://designsystem.dn.se/?path=/docs/foundations-icons--docs)
|
|
14
|
+
*
|
|
15
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
16
|
+
* `@use '@bonniernews/dn-design-system-web/components/icon/icon.scss'`
|
|
17
|
+
*
|
|
18
|
+
* ###There are three ways to use icons from DS:
|
|
19
|
+
* Use Icon from sprite: `IconUse({})`, this is the **recomended** way since this reduces the html output.
|
|
20
|
+
* Use Icon with wrapper: `IconWithWrapper({})`, the component itself uses the icons from the sprite but wraps it with a div and takes properties like size and color
|
|
21
|
+
* Use Icon from foundations: `Icon({})`, only use this if you need an inline icon, this will output the entire svg wherever it is used.
|
|
22
|
+
*/
|
|
23
|
+
export declare const IconWithWrapper: ({ iconName, size, color, attributes, classNames, forcePx }: IconProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Icons } from "../../types/token-types/icons";
|
|
2
|
+
export interface PictogramProps {
|
|
3
|
+
variant?: 'brand' | 'business';
|
|
4
|
+
iconName: Icons;
|
|
5
|
+
size?: 'large' | 'small';
|
|
6
|
+
classNames?: string;
|
|
7
|
+
attributes?: object;
|
|
8
|
+
forcePx?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/Pictogram](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/pictogram)
|
|
12
|
+
* - Storybook: [Pictogram](https://designsystem.dn.se/?path=/docs/article-Pictogram--docs)
|
|
13
|
+
*
|
|
14
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
15
|
+
* `@use '@bonniernews/dn-design-system-web/components/pictogram/pictogram.scss'`
|
|
16
|
+
*/
|
|
17
|
+
export declare const Pictogram: ({ variant, iconName, size, classNames, attributes, forcePx }: PictogramProps) => import("preact").JSX.Element;
|
|
@@ -12,3 +12,9 @@ import { Footer } from "./components/footer/footer";
|
|
|
12
12
|
export { Footer };
|
|
13
13
|
import { Spinner } from "./components/spinner/spinner";
|
|
14
14
|
export { Spinner };
|
|
15
|
+
import { IconWithWrapper } from "./components/icon-with-wrapper/icon-with-wrapper";
|
|
16
|
+
export { IconWithWrapper };
|
|
17
|
+
import { IconSprite } from "./components/icon-sprite/icon-sprite";
|
|
18
|
+
export { IconSprite };
|
|
19
|
+
import { IconUse } from "./components/icon-sprite/icon-sprite";
|
|
20
|
+
export { IconUse };
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [21.1.10](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@21.1.9...@bonniernews/dn-design-system-web@21.1.10) (2024-12-04)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **web:** icons, including sprite and pictogram, as .tsx ([#1523](https://github.com/BonnierNews/dn-design-system/issues/1523)) ([17dc7f9](https://github.com/BonnierNews/dn-design-system/commit/17dc7f9faf88d4c86815e158267a59aad34be689))
|
|
13
|
+
|
|
7
14
|
## [21.1.9](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@21.1.8...@bonniernews/dn-design-system-web@21.1.9) (2024-11-29)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { formatClassString } from "../../helpers/formatClassString";
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import SpriteFile from '../../foundations/icons/sprite.svg';
|
|
4
|
+
|
|
5
|
+
export interface IconProps {
|
|
6
|
+
iconName: string;
|
|
7
|
+
classNames?: string;
|
|
8
|
+
attributes?: object;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-sprite)
|
|
13
|
+
* - Storybook: [icon](https://designsystem.dn.se/?path=/docs/foundations-icons--docs)
|
|
14
|
+
*
|
|
15
|
+
* The IconUse component is used to render a specific icon from the sprite, but mostly we will use the IconWithWrapper component.
|
|
16
|
+
* The IconSprite component is only used to export the sprite file.
|
|
17
|
+
*
|
|
18
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
19
|
+
* `@use '@bonniernews/dn-design-system-web/components/icon/icon.scss'`
|
|
20
|
+
*/
|
|
21
|
+
export const IconUse = ({ iconName, classNames, attributes }: IconProps) => {
|
|
22
|
+
const componentClassName = 'ds-icon';
|
|
23
|
+
|
|
24
|
+
const classes = formatClassString([
|
|
25
|
+
componentClassName,
|
|
26
|
+
`${componentClassName}--sprite`,
|
|
27
|
+
`${componentClassName}--${iconName}`,
|
|
28
|
+
classNames,
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<i className={classes} { ...attributes }>
|
|
33
|
+
<svg><use xlinkHref={`#ds-${ iconName }`}></use></svg>
|
|
34
|
+
</i>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
export const IconSprite = () => <SpriteFile />
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import colorVariables from '@bonniernews/dn-design-system-web/tokens/colors-css-variables.json';
|
|
2
|
+
import { IconColors } from '../../types/token-types/colors';
|
|
3
|
+
import { Icons } from '../../types/token-types/icons';
|
|
4
|
+
|
|
5
|
+
import { formatClassString } from "../../helpers/formatClassString";
|
|
6
|
+
import { IconUse } from "../icon-sprite/icon-sprite";
|
|
7
|
+
|
|
8
|
+
export interface IconProps {
|
|
9
|
+
iconName: Icons;
|
|
10
|
+
size?: number;
|
|
11
|
+
color?: IconColors;
|
|
12
|
+
classNames?: string;
|
|
13
|
+
attributes?: object;
|
|
14
|
+
forcePx?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-sprite)
|
|
19
|
+
* - Storybook: [icon](https://designsystem.dn.se/?path=/docs/foundations-icons--docs)
|
|
20
|
+
*
|
|
21
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
22
|
+
* `@use '@bonniernews/dn-design-system-web/components/icon/icon.scss'`
|
|
23
|
+
*
|
|
24
|
+
* ###There are three ways to use icons from DS:
|
|
25
|
+
* Use Icon from sprite: `IconUse({})`, this is the **recomended** way since this reduces the html output.
|
|
26
|
+
* Use Icon with wrapper: `IconWithWrapper({})`, the component itself uses the icons from the sprite but wraps it with a div and takes properties like size and color
|
|
27
|
+
* Use Icon from foundations: `Icon({})`, only use this if you need an inline icon, this will output the entire svg wherever it is used.
|
|
28
|
+
*/
|
|
29
|
+
export const IconWithWrapper = ({ iconName, size = 24, color = "icon-primary", attributes, classNames, forcePx }: IconProps) => {
|
|
30
|
+
const componentClassName = 'ds-icon-wrapper';
|
|
31
|
+
|
|
32
|
+
const classes = formatClassString([
|
|
33
|
+
componentClassName,
|
|
34
|
+
`${componentClassName}--sprite`,
|
|
35
|
+
`${componentClassName}--${iconName}`,
|
|
36
|
+
forcePx && 'ds-force-px',
|
|
37
|
+
classNames,
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
const iconSize = forcePx ? `${size}px` : `${size/16}rem`;
|
|
41
|
+
const iconColor = colorVariables[color];
|
|
42
|
+
const styles = {
|
|
43
|
+
width: iconSize,
|
|
44
|
+
height: iconSize,
|
|
45
|
+
color: iconColor
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className={ classes } style={styles} { ...attributes }>
|
|
50
|
+
<IconUse iconName={iconName} />
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { formatClassString } from "../../helpers/formatClassString";
|
|
2
|
+
import { Icons } from "../../types/token-types/icons";
|
|
3
|
+
import { IconUse } from "../icon-sprite/icon-sprite";
|
|
4
|
+
|
|
5
|
+
export interface PictogramProps {
|
|
6
|
+
variant?: 'brand' | 'business';
|
|
7
|
+
iconName: Icons;
|
|
8
|
+
size?: 'large' | 'small';
|
|
9
|
+
classNames?: string;
|
|
10
|
+
attributes?: object;
|
|
11
|
+
forcePx?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/Pictogram](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/pictogram)
|
|
16
|
+
* - Storybook: [Pictogram](https://designsystem.dn.se/?path=/docs/article-Pictogram--docs)
|
|
17
|
+
*
|
|
18
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
19
|
+
* `@use '@bonniernews/dn-design-system-web/components/pictogram/pictogram.scss'`
|
|
20
|
+
*/
|
|
21
|
+
export const Pictogram = ({ variant = 'brand', iconName, size = 'small', classNames, attributes, forcePx }: PictogramProps) => {
|
|
22
|
+
const componentClassName = 'ds-pictogram';
|
|
23
|
+
|
|
24
|
+
const classes = formatClassString([
|
|
25
|
+
componentClassName,
|
|
26
|
+
`${componentClassName}--${variant}`,
|
|
27
|
+
`${componentClassName}--${size}`,
|
|
28
|
+
forcePx && 'ds-force-px',
|
|
29
|
+
classNames,
|
|
30
|
+
])
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className={classes} {...attributes } aria-hidden="true">
|
|
34
|
+
<IconUse iconName={iconName} />
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -6,7 +6,7 @@ Spinner
|
|
|
6
6
|
|
|
7
7
|
The component will not include styling by itself. Make sure to include the right styles for the component. See example below: `@use '@bonniernews/dn-design-system-web/components/spinner/spinner.scss'`
|
|
8
8
|
|
|
9
|
-
<table class="docblock-argstable sb-unstyled css-v2ifgj"><thead class="docblock-argstable-head"><tr><th><span>Name</span></th><th><span>Description</span></th><th><span>Default</span></th></tr></thead><tbody class="docblock-argstable-body"><tr><td class="css-4lbn0a"><span class="css-in3yi3">variant</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">"
|
|
9
|
+
<table class="docblock-argstable sb-unstyled css-v2ifgj"><thead class="docblock-argstable-head"><tr><th><span>Name</span></th><th><span>Description</span></th><th><span>Default</span></th></tr></thead><tbody class="docblock-argstable-body"><tr><td class="css-4lbn0a"><span class="css-in3yi3">variant</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">"primary"</span><span class="css-o1d7ko">"secondary"</span><span class="css-o1d7ko">"brand"</span><span class="css-o1d7ko">"onBrand"</span><span class="css-o1d7ko">"onBusiness"</span><span class="css-o1d7ko">"staticBlack"</span><span class="css-o1d7ko">"staticWhite"</span></div></div></td><td><div class="css-13nzt7e"><span class="css-o1d7ko">"primary"</span></div></td></tr><tr><td class="css-4lbn0a"><span class="css-in3yi3">size</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">"large"</span><span class="css-o1d7ko">"small"</span><span class="css-o1d7ko">"xsmall"</span></div></div></td><td><div class="css-13nzt7e"><span class="css-o1d7ko">"large"</span></div></td></tr><tr><td class="css-4lbn0a"><span class="css-in3yi3">forcePx</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">boolean</span></div></div></td><td><span>-</span></td></tr><tr><td class="css-4lbn0a"><span class="css-in3yi3">classNames</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">string</span></div></div></td><td><span>-</span></td></tr><tr><td class="css-4lbn0a"><span class="css-in3yi3">attributes</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">object</span></div></div></td><td><span>-</span></td></tr></tbody></table>
|
|
10
10
|
|
|
11
11
|
<pre class="prismjs css-4zr3vl"><div class="language-jsx css-zye6j" style="white-space: pre;"><span class="token tag punctuation"><</span><span class="token tag class-name">Spinner</span><span class="token tag">
|
|
12
12
|
</span><span class="token tag"> </span><span class="token tag attr-name">size</span><span class="token tag attr-value punctuation attr-equals">=</span><span class="token tag attr-value punctuation">"</span><span class="token tag attr-value">large</span><span class="token tag attr-value punctuation">"</span><span class="token tag">
|
package/index.d.ts
ADDED
package/index.tsx
CHANGED
|
@@ -18,3 +18,12 @@ export { Footer };
|
|
|
18
18
|
|
|
19
19
|
import { Spinner } from "./components/spinner/spinner";
|
|
20
20
|
export { Spinner };
|
|
21
|
+
|
|
22
|
+
import { IconWithWrapper } from "./components/icon-with-wrapper/icon-with-wrapper";
|
|
23
|
+
export { IconWithWrapper };
|
|
24
|
+
|
|
25
|
+
import { IconSprite } from "./components/icon-sprite/icon-sprite";
|
|
26
|
+
export { IconSprite };
|
|
27
|
+
|
|
28
|
+
import { IconUse } from "./components/icon-sprite/icon-sprite";
|
|
29
|
+
export { IconUse };
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonniernews/dn-design-system-web",
|
|
3
|
-
"version": "21.1.
|
|
3
|
+
"version": "21.1.10",
|
|
4
4
|
"description": "DN design system for web.",
|
|
5
5
|
"main": "index.tsx",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"source": "index.tsx",
|
|
8
8
|
"homepage": "https://github.com/BonnierNews/dn-design-system/tree/main/web/src#readme",
|
|
9
|
+
"types": "./@types/index.d.ts",
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "git+https://github.com/BonnierNews/dn-design-system.git",
|
|
@@ -21,10 +22,7 @@
|
|
|
21
22
|
"import": "./preact/components.esm.js",
|
|
22
23
|
"require": "./preact/components.cjs"
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
-
"import": "./react/components.esm.js",
|
|
26
|
-
"require": "./react/components.cjs"
|
|
27
|
-
},
|
|
25
|
+
"./@types": "./@types",
|
|
28
26
|
"./assets/*.tsx": "./assets/*.tsx",
|
|
29
27
|
"./assets/*.njk": "./assets/*.njk",
|
|
30
28
|
"./assets/*.scss": "./assets/*.scss",
|
|
@@ -37,19 +35,11 @@
|
|
|
37
35
|
"./package.json": "./package.json"
|
|
38
36
|
},
|
|
39
37
|
"peerDependencies": {
|
|
40
|
-
"preact": "^10.24.0"
|
|
41
|
-
"react": "^18.3.1",
|
|
42
|
-
"react-dom": "^18.3.1"
|
|
38
|
+
"preact": "^10.24.0"
|
|
43
39
|
},
|
|
44
40
|
"peerDependenciesMeta": {
|
|
45
41
|
"preact": {
|
|
46
42
|
"optional": true
|
|
47
|
-
},
|
|
48
|
-
"react": {
|
|
49
|
-
"optional": true
|
|
50
|
-
},
|
|
51
|
-
"react-dom": {
|
|
52
|
-
"optional": true
|
|
53
43
|
}
|
|
54
44
|
},
|
|
55
45
|
"devDependencies": {
|
|
@@ -60,8 +50,6 @@
|
|
|
60
50
|
"conventional-changelog-conventionalcommits": "^6.1.0",
|
|
61
51
|
"postcss": "8.4.31",
|
|
62
52
|
"preact": "^10.24.0",
|
|
63
|
-
"react": "^18.3.1",
|
|
64
|
-
"react-dom": "^18.3.1",
|
|
65
53
|
"release-it": "^17.0.0",
|
|
66
54
|
"stylelint": "^15.11.0",
|
|
67
55
|
"stylelint-config-recommended-scss": "^13.1.0",
|