@bonniernews/dn-design-system-web 32.1.1 → 32.1.2-beta.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.
@@ -0,0 +1,79 @@
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+
3
+ a.ds-teaser--counter.ds-teaser {
4
+ color: inherit;
5
+ text-decoration: none;
6
+ }
7
+
8
+ .ds-teaser--counter.ds-teaser {
9
+ display: grid;
10
+ grid-template-columns: auto auto;
11
+ background-color: $ds-color-surface-primary;
12
+ gap: ds-spacing($ds-s-075);
13
+ padding: ds-spacing($ds-s-075);
14
+
15
+ .ds-teaser__content {
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: ds-spacing($ds-s-100);
19
+ justify-content: space-between;
20
+ }
21
+
22
+ .ds-teaser--counter__title {
23
+ @include ds-typography(
24
+ $ds-typography-functional-heading-xs,
25
+ $fontWeight: $ds-fontweight-regular,
26
+ $lineHeight: $ds-lineheight-md
27
+ );
28
+ margin: 0;
29
+ }
30
+
31
+ .ds-teaser--counter__title--highlighted {
32
+ font-weight: $ds-fontweight-bold;
33
+ }
34
+
35
+ .ds-teaser--counter__counter-wrapper {
36
+ align-items: center;
37
+ display: flex;
38
+ gap: ds-spacing($ds-s-050);
39
+ }
40
+
41
+ .ds-teaser--counter__list {
42
+ @include ds-typography($ds-typography-functional-heading-sm, $fontWeight: $ds-fontweight-regular);
43
+ display: flex;
44
+ font-variant-numeric: tabular-nums;
45
+ gap: ds-spacing($ds-s-012);
46
+ list-style: none;
47
+ margin: 0;
48
+ padding: 0;
49
+
50
+ .ds-teaser--counter__item {
51
+ background-color: $ds-color-brand-600;
52
+ border-radius: ds-border-radius($ds-s-025);
53
+ color: $ds-color-text-on-brand;
54
+ padding: ds-spacing($ds-s-012) ds-spacing($ds-s-025);
55
+ }
56
+ }
57
+
58
+ .ds-teaser--counter__counter-text {
59
+ @include ds-typography($ds-typography-functional-meta-md);
60
+ margin: 0;
61
+ }
62
+ .ds-teaser-image {
63
+ display: flex;
64
+ justify-content: flex-end;
65
+ max-height: 130px;
66
+ min-height: 86px;
67
+ height: 100%;
68
+ margin: 0;
69
+ }
70
+
71
+ .picture--placeholder {
72
+ height: 100%;
73
+ }
74
+
75
+ .picture--placeholder,
76
+ .picture__img {
77
+ border-radius: ds-border-radius($ds-s-025);
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "32.1.1",
3
+ "version": "32.1.2-beta.0",
4
4
  "description": "DN design system for web.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/BonnierNews/dn-design-system/tree/main/web/src#readme",
@@ -0,0 +1,26 @@
1
+ export interface TeaserCounterProps {
2
+ title: string;
3
+ counterText: string;
4
+ subtitle?: string;
5
+ areaType?: 'right' | 'bauta';
6
+ targetLink?: string;
7
+ mediaHtml?: string;
8
+ counterDate?: string;
9
+ countdown?: boolean;
10
+ counterNumber?: number;
11
+ classNames?: string;
12
+ /** Ex. { target: "_blank", "data-test": "lorem ipsum" } */
13
+ attributes?: object;
14
+ }
15
+ /**
16
+ * Also known as "På Plats-puffen".
17
+ *
18
+ * In the CMS title will be set to a location like "Kiev, Ukraina" or "USA" and text is usually set to some author names like "Jan Banan och Kalle Kula"
19
+ *
20
+ * - GitHub: [BonnierNews/dn-design-system/../web/src/components/teaser-onsite](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/teaser-counter)
21
+ * - Storybook: [TeaserCounter](https://designsystem.dn.se/?path=/docs/section-teaser-counter--docs)
22
+ *
23
+ * The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
24
+ * `@use '@bonniernews/dn-design-system-web/components/teaser-counter/teaser-counter.scss'`
25
+ */
26
+ export declare const TeaserCounter: ({ areaType, targetLink, classNames, attributes, mediaHtml, counterText, countdown, counterDate, counterNumber, title, subtitle, }: TeaserCounterProps) => import("preact").JSX.Element;
@@ -0,0 +1,78 @@
1
+ // ../src/helpers/formatClassString.ts
2
+ var formatClassString = (classesArray) => {
3
+ return classesArray.filter((x) => !!x).join(" ");
4
+ };
5
+
6
+ // ../src/components/teaser-card/teaser-card.tsx
7
+ import { jsx } from "preact/jsx-runtime";
8
+ var TeaserCard = ({ areaType, targetLink, theme = "nyheter", classes, attributes, children }) => {
9
+ const componentClassName = "ds-teaser";
10
+ const classNames = formatClassString([
11
+ componentClassName,
12
+ areaType && `${componentClassName}--${areaType}`,
13
+ areaType == "bauta" && "ds-dark",
14
+ `ds-theme--${theme}`,
15
+ classes
16
+ ]);
17
+ if (targetLink) {
18
+ return /* @__PURE__ */ jsx("a", { className: classNames, href: targetLink, ...attributes, children });
19
+ }
20
+ return /* @__PURE__ */ jsx("div", { className: classNames, ...attributes, children });
21
+ };
22
+
23
+ // ../src/helpers/teaser.tsx
24
+ import { jsx as jsx2 } from "preact/jsx-runtime";
25
+ var Media = ({ mediaHtml, rounded }) => {
26
+ const classNames = "ds-teaser__media" + (rounded ? " ds-teaser__media--rounded" : "");
27
+ return mediaHtml ? /* @__PURE__ */ jsx2("div", { className: classNames, dangerouslySetInnerHTML: { __html: mediaHtml } }) : null;
28
+ };
29
+ var Content = ({ children }) => {
30
+ return /* @__PURE__ */ jsx2("div", { className: "ds-teaser__content", children });
31
+ };
32
+
33
+ // ../src/components/teaser-counter/teaser-counter.tsx
34
+ import { jsx as jsx3, jsxs } from "preact/jsx-runtime";
35
+ var TeaserCounter = ({
36
+ areaType,
37
+ targetLink,
38
+ classNames,
39
+ attributes,
40
+ mediaHtml,
41
+ counterText,
42
+ countdown,
43
+ counterDate,
44
+ counterNumber,
45
+ title,
46
+ subtitle
47
+ }) => {
48
+ const componentClassName = "ds-teaser--counter";
49
+ const classes = formatClassString([componentClassName, classNames]);
50
+ const mergedAttributes = {
51
+ ...attributes,
52
+ "data-counter-date": counterDate,
53
+ ...countdown ? { "data-countdown": countdown } : {}
54
+ };
55
+ return /* @__PURE__ */ jsxs(TeaserCard, { ...{ areaType, targetLink, classes, attributes: mergedAttributes }, children: [
56
+ /* @__PURE__ */ jsxs(Content, { children: [
57
+ title && /* @__PURE__ */ jsxs("h2", { className: `${componentClassName}__title`, children: [
58
+ /* @__PURE__ */ jsx3("span", { className: `${componentClassName}__title--highlighted`, children: title }),
59
+ subtitle && ` \u2013 ${subtitle}`
60
+ ] }),
61
+ (counterNumber || counterText) && /* @__PURE__ */ jsxs("div", { className: `${componentClassName}__counter-wrapper`, children: [
62
+ counterNumber && /* @__PURE__ */ jsx3("ul", { className: `${componentClassName}__list`, children: counterNumber.toString().split("").map((digit, index) => /* @__PURE__ */ jsx3("li", { className: `${componentClassName}__item`, children: digit }, index)) }),
63
+ counterText && /* @__PURE__ */ jsx3(
64
+ "p",
65
+ {
66
+ className: `${componentClassName}__counter-text`,
67
+ dangerouslySetInnerHTML: { __html: counterText }
68
+ }
69
+ )
70
+ ] })
71
+ ] }),
72
+ /* @__PURE__ */ jsx3(Media, { ...{ mediaHtml } })
73
+ ] });
74
+ };
75
+ export {
76
+ TeaserCounter
77
+ };
78
+ //# sourceMappingURL=teaser-counter.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../helpers/formatClassString.ts", "../../../components/teaser-card/teaser-card.tsx", "../../../helpers/teaser.tsx", "../../../components/teaser-counter/teaser-counter.tsx"],
4
+ "sourcesContent": ["export const formatClassString = (classesArray: (string|undefined|false)[]): string => {\n return classesArray.filter(x => !!x).join(' ');\n}\n", "import { formatClassString } from \"@bonniernews/dn-design-system-web/helpers/formatClassString.ts\";\nimport { ComponentChildren } from \"preact\";\n\nexport interface TeaserCardsProps {\n areaType?: 'right' | 'bauta' | 'bautaxl';\n targetLink?: string;\n theme?: 'kultur' | 'nyheter';\n classes?: string;\n /** Ex. { target: \"_blank\", \"data-test\": \"lorem ipsum\" } */\n attributes?: object;\n children: ComponentChildren;\n}\n\n/**\n * - GitHub: [BonnierNews/dn-design-system/../web/src/components/teaser-card](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/teaser-card)\n * - Storybook: [Subcomponents > TeaserCard](https://designsystem.dn.se/?path=/docs/section-subcomponents-teaserdot--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/assets/teaser/teaser.scss'`\n */\nexport const TeaserCard = ({ areaType, targetLink, theme = 'nyheter', classes, attributes, children }: TeaserCardsProps) => {\n const componentClassName = 'ds-teaser';\n\n const classNames = formatClassString([\n componentClassName,\n areaType && `${componentClassName}--${areaType}`,\n areaType == 'bauta' && 'ds-dark',\n `ds-theme--${theme}`,\n classes,\n ])\n\n if (targetLink) {\n return (\n <a className={classNames} href={targetLink } {...attributes}>\n { children }\n </a>\n );\n }\n\n return (\n <div className={classNames}{...attributes}>\n { children }\n </div>\n );\n};\n", "import { ComponentChildren } from \"preact\";\n\ninterface MediaProps {\n mediaHtml?: string;\n rounded?: boolean;\n}\n\nexport const Media = ({ mediaHtml, rounded }: MediaProps) => {\n const classNames = 'ds-teaser__media' + (rounded ? ' ds-teaser__media--rounded' : '');\n return mediaHtml ? (<div className={classNames} dangerouslySetInnerHTML={{ __html: mediaHtml }} />) : (null)\n}\n\ninterface ContentProps {\n children: ComponentChildren;\n}\nexport const Content = ({ children }: ContentProps) => {\n return (<div className=\"ds-teaser__content\">\n {children}\n </div>)\n}\n\ninterface TitleProps {\n title?: string;\n}\nexport const Title = ({ title }: TitleProps) => {\n return title ? (<h2 className=\"ds-teaser__title\">{title}</h2>) : (null)\n}\n\ninterface BodyProps {\n text?: string;\n}\nexport const Body = ({ text }: BodyProps) => {\n return text ? (<p className=\"ds-teaser__text\">{text}</p>) : (null)\n}\n", "import { TeaserCard } from '@bonniernews/dn-design-system-web/components/teaser-card/teaser-card.tsx'\nimport { formatClassString } from '@bonniernews/dn-design-system-web/helpers/formatClassString.ts'\nimport { Content, Media } from '@bonniernews/dn-design-system-web/helpers/teaser.tsx'\nexport interface TeaserCounterProps {\n title: string\n counterText: string\n subtitle?: string\n areaType?: 'right' | 'bauta'\n targetLink?: string\n mediaHtml?: string\n counterDate?: string\n countdown?: boolean\n counterNumber?: number\n classNames?: string\n /** Ex. { target: \"_blank\", \"data-test\": \"lorem ipsum\" } */\n attributes?: object\n}\n\n/**\n * Also known as \"P\u00E5 Plats-puffen\".\n *\n * In the CMS title will be set to a location like \"Kiev, Ukraina\" or \"USA\" and text is usually set to some author names like \"Jan Banan och Kalle Kula\"\n *\n * - GitHub: [BonnierNews/dn-design-system/../web/src/components/teaser-onsite](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/teaser-counter)\n * - Storybook: [TeaserCounter](https://designsystem.dn.se/?path=/docs/section-teaser-counter--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/teaser-counter/teaser-counter.scss'`\n */\nexport const TeaserCounter = ({\n areaType,\n targetLink,\n classNames,\n attributes,\n mediaHtml,\n counterText,\n countdown,\n counterDate,\n counterNumber,\n title,\n subtitle,\n}: TeaserCounterProps) => {\n const componentClassName = 'ds-teaser--counter'\n const classes = formatClassString([componentClassName, classNames])\n\n const mergedAttributes = {\n ...attributes,\n 'data-counter-date': counterDate,\n ...(countdown ? { 'data-countdown': countdown } : {}),\n }\n\n return (\n <TeaserCard {...{ areaType, targetLink, classes, attributes: mergedAttributes }}>\n <Content>\n {title && (\n <h2 className={`${componentClassName}__title`}>\n <span className={`${componentClassName}__title--highlighted`}>{title}</span>\n {subtitle && ` \u2013 ${subtitle}`}\n </h2>\n )}\n\n {(counterNumber || counterText) && (\n <div className={`${componentClassName}__counter-wrapper`}>\n {counterNumber && (\n <ul className={`${componentClassName}__list`}>\n {counterNumber\n .toString()\n .split('')\n .map((digit, index) => (\n <li key={index} className={`${componentClassName}__item`}>\n {digit}\n </li>\n ))}\n </ul>\n )}\n\n {counterText && (\n <p\n className={`${componentClassName}__counter-text`}\n dangerouslySetInnerHTML={{ __html: counterText }}\n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