@bonniernews/dn-design-system-web 32.7.47 → 32.7.48
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [32.7.48](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.7.47...@bonniernews/dn-design-system-web@32.7.48) (2025-08-18)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **app:** typography fontscale aware ([#1867](https://github.com/BonnierNews/dn-design-system/issues/1867)) ([7023ecd](https://github.com/BonnierNews/dn-design-system/commit/7023ecd287da2e35bba322e960714fe0e28a60ee))
|
|
13
|
+
* **web:** badge component as TSX ([#1865](https://github.com/BonnierNews/dn-design-system/issues/1865)) ([1b5dbba](https://github.com/BonnierNews/dn-design-system/commit/1b5dbba2f60aaf677de378a4719d20f19f86eddc))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Maintenance
|
|
17
|
+
|
|
18
|
+
* prerelease packages ([a04b181](https://github.com/BonnierNews/dn-design-system/commit/a04b181cd7b556abd79e63338fbdea879638d9fe))
|
|
19
|
+
|
|
7
20
|
## [32.7.47](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.7.46...@bonniernews/dn-design-system-web@32.7.47) (2025-08-15)
|
|
8
21
|
|
|
9
22
|
|
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
- Storybook (Latest): [Badge](https://designsystem-latest.dn.se/?path=/docs/basic-badge--docs)
|
|
1
|
+
Badge
|
|
2
|
+
=====
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/web/src/components/badge](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/badge)
|
|
5
|
+
* Storybook: [Badge](https://designsystem.dn.se/?path=/docs/basic-badge--docs)
|
|
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/badge/badge.scss'`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Name | Description | Default |
|
|
10
|
+
|:--- | :--- | :--- |
|
|
11
|
+
| figure | number | \- |
|
|
12
|
+
| forcePx | boolean | \- |
|
|
13
|
+
| classNames | Ex. "my-special-class"<br />string | \- |
|
|
14
|
+
| attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />Record<string, unknown> | \- |
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|classNames | String | no | | | Ex. "my-special-class" |
|
|
15
|
-
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size |
|
|
16
|
-
|
|
17
|
-
## Minimum requirement example
|
|
18
|
-
|
|
19
|
-
### Nunjucks
|
|
20
|
-
|
|
21
|
-
These are copy paste friendly examples to quickliy get started using a component.
|
|
22
|
-
|
|
23
|
-
```html
|
|
24
|
-
{% from '@bonniernews/dn-design-system-web/components/badge/badge.njk' import Badge %}
|
|
25
|
-
|
|
26
|
-
{{ Badge({
|
|
27
|
-
figure: 2
|
|
28
|
-
})}}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### SCSS
|
|
32
|
-
```scss
|
|
33
|
-
@use "@bonniernews/dn-design-system-web/components/badge/badge";
|
|
34
|
-
```
|
|
16
|
+
```jsx
|
|
17
|
+
<Badge />
|
|
18
|
+
```
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SharedProps } from '@bonniernews/dn-design-system-web/assets/types/shared-props.ts';
|
|
2
|
+
export interface BadgeProps extends SharedProps {
|
|
3
|
+
figure?: number;
|
|
4
|
+
forcePx?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* - GitHub: [BonnierNews/dn-design-system/web/src/components/badge](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/badge)
|
|
8
|
+
* - Storybook: [Badge](https://designsystem.dn.se/?path=/docs/basic-badge--docs)
|
|
9
|
+
*
|
|
10
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
11
|
+
* `@use '@bonniernews/dn-design-system-web/components/badge/badge.scss'`
|
|
12
|
+
*/
|
|
13
|
+
export declare const Badge: ({ figure, forcePx, classNames, attributes }: BadgeProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ../src/helpers/formatClassString.ts
|
|
2
|
+
var formatClassString = (classesArray) => {
|
|
3
|
+
return classesArray.filter((x) => !!x).join(" ");
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// ../src/components/badge/badge.tsx
|
|
7
|
+
import { jsx } from "preact/jsx-runtime";
|
|
8
|
+
var Badge = ({ figure, forcePx, classNames, attributes }) => {
|
|
9
|
+
const componentClassName = "ds-badge";
|
|
10
|
+
let variant = "empty";
|
|
11
|
+
if (figure) {
|
|
12
|
+
variant = figure < 10 ? "single" : "double";
|
|
13
|
+
}
|
|
14
|
+
const classes = formatClassString([
|
|
15
|
+
componentClassName,
|
|
16
|
+
`${componentClassName}--${variant}`,
|
|
17
|
+
forcePx && "ds-force-px",
|
|
18
|
+
classNames
|
|
19
|
+
]);
|
|
20
|
+
return /* @__PURE__ */ jsx("div", { className: classes, ...attributes, children: /* @__PURE__ */ jsx("span", { className: "ds-badge__inner", children: figure && (variant === "double" ? "9+" : figure) }) });
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
Badge
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=badge.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../helpers/formatClassString.ts", "../../../components/badge/badge.tsx"],
|
|
4
|
+
"sourcesContent": ["export const formatClassString = (classesArray: (string | undefined | false)[]): string => {\n return classesArray.filter((x) => !!x).join(' ')\n}\n", "import type { SharedProps } from '@bonniernews/dn-design-system-web/assets/types/shared-props.ts'\n\nimport { formatClassString } from '@bonniernews/dn-design-system-web/helpers/formatClassString.ts'\n\nexport interface BadgeProps extends SharedProps {\n figure?: number\n forcePx?: boolean\n}\n\n/**\n * - GitHub: [BonnierNews/dn-design-system/web/src/components/badge](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/badge)\n * - Storybook: [Badge](https://designsystem.dn.se/?path=/docs/basic-badge--docs)\n *\n * The component will not include styling by itself. Make sure to include the right styles for the component. See example below:\n * `@use '@bonniernews/dn-design-system-web/components/badge/badge.scss'`\n */\nexport const Badge = ({ figure, forcePx, classNames, attributes }: BadgeProps) => {\n const componentClassName = 'ds-badge'\n let variant = 'empty'\n\n if (figure) {\n variant = figure < 10 ? 'single' : 'double'\n }\n\n const classes = formatClassString([\n componentClassName,\n `${componentClassName}--${variant}`,\n forcePx && 'ds-force-px',\n classNames,\n ])\n\n return (\n <div className={classes} {...attributes}>\n <span className='ds-badge__inner'>{figure && (variant === 'double' ? '9+' : figure)}</span>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,oBAAoB,CAAC,iBAAyD;AACzF,SAAO,aAAa,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG;AACjD;;;AC+BM;AAjBC,IAAM,QAAQ,CAAC,EAAE,QAAQ,SAAS,YAAY,WAAW,MAAkB;AAChF,QAAM,qBAAqB;AAC3B,MAAI,UAAU;AAEd,MAAI,QAAQ;AACV,cAAU,SAAS,KAAK,WAAW;AAAA,EACrC;AAEA,QAAM,UAAU,kBAAkB;AAAA,IAChC;AAAA,IACA,GAAG,kBAAkB,KAAK,OAAO;AAAA,IACjC,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AAED,SACE,oBAAC,SAAI,WAAW,SAAU,GAAG,YAC3B,8BAAC,UAAK,WAAU,mBAAmB,qBAAW,YAAY,WAAW,OAAO,SAAQ,GACtF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{% macro Badge(params) %}
|
|
2
|
-
{% set componentClassName = "ds-badge" %}
|
|
3
|
-
{% set classNamePrefix = componentClassName + "--" %}
|
|
4
|
-
{% set figure = params.figure %}
|
|
5
|
-
|
|
6
|
-
{% if figure and figure | string | length == 1 %}
|
|
7
|
-
{% set variant = "single" %}
|
|
8
|
-
{% elif figure %}
|
|
9
|
-
{% set figure = "9+" %}
|
|
10
|
-
{% set variant = "double" %}
|
|
11
|
-
{% else %}
|
|
12
|
-
{% set variant = "empty" %}
|
|
13
|
-
{% endif%}
|
|
14
|
-
|
|
15
|
-
{%- set classes = [
|
|
16
|
-
componentClassName,
|
|
17
|
-
classNamePrefix + variant,
|
|
18
|
-
"ds-force-px" if params.forcePx,
|
|
19
|
-
params.classNames if params.classNames
|
|
20
|
-
] | join(" ") %}
|
|
21
|
-
|
|
22
|
-
<div class="{{ classes }}">
|
|
23
|
-
<span class="{{ componentClassName + '__inner'}}">{{- figure | safe if figure -}}</span>
|
|
24
|
-
</div>
|
|
25
|
-
{% endmacro %}
|