@ndlib/component-library 0.0.84 → 0.0.86
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/dist/components/composites/Seo/index.js +2 -2
- package/dist/components/composites/StructuredData/index.d.ts +2 -1
- package/dist/components/composites/StructuredData/index.js +3 -3
- package/dist/components/elements/text/Paragraph/Paragraph.stories.d.ts +1 -0
- package/dist/components/elements/text/Paragraph/Paragraph.stories.js +6 -0
- package/dist/components/elements/text/Paragraph/index.d.ts +1 -0
- package/dist/components/elements/text/Paragraph/index.js +12 -2
- package/dist/components/elements/text/ReadMore/index.js +6 -3
- package/dist/utils/misc.d.ts +4 -0
- package/dist/utils/misc.js +5 -0
- package/dist/utils/misc.test.d.ts +1 -0
- package/dist/utils/misc.test.js +13 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { siteMetadata } from './siteMetadata';
|
|
3
|
-
export const Seo = ({ title, description, image, nofollow, noindex, }) => {
|
|
3
|
+
export const Seo = ({ title, description, image, nofollow, noindex, pathname, }) => {
|
|
4
4
|
const { title: defaultTitle, description: defaultDescription, image: defaultImage, nofollow: defaultNoindex, noindex: defaultNofollow, siteUrl, twitterUsername, } = siteMetadata();
|
|
5
5
|
const seo = {
|
|
6
6
|
title: title || defaultTitle,
|
|
7
7
|
description: description || defaultDescription,
|
|
8
8
|
image: image ? image : defaultImage,
|
|
9
|
-
url: siteUrl +
|
|
9
|
+
url: siteUrl + pathname || '',
|
|
10
10
|
nofollow: nofollow || defaultNofollow,
|
|
11
11
|
noindex: noindex || defaultNoindex,
|
|
12
12
|
twitterUsername,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export type StructuredDataProps = {
|
|
3
3
|
title?: string;
|
|
4
|
+
pathname?: string;
|
|
4
5
|
description?: string;
|
|
5
6
|
siteUrl?: string;
|
|
6
7
|
nofollow?: string;
|
|
@@ -33,6 +34,6 @@ export type StructuredDataProps = {
|
|
|
33
34
|
publishedDate: string;
|
|
34
35
|
}[];
|
|
35
36
|
};
|
|
36
|
-
export declare const getStructuredDataSchemas: ({ title, description, nofollow, noindex, image, events, news, }: StructuredDataProps) => string[];
|
|
37
|
+
export declare const getStructuredDataSchemas: ({ title, pathname, description, nofollow, noindex, image, events, news, }: StructuredDataProps) => string[];
|
|
37
38
|
export declare const StructuredData: React.FC<StructuredDataProps>;
|
|
38
39
|
export default StructuredData;
|
|
@@ -3,7 +3,7 @@ import { siteMetadata } from './siteMetadata';
|
|
|
3
3
|
import { stringifyWebpageSchema } from './sdWebsite';
|
|
4
4
|
import { stringifyEventSchema } from './sdEvent';
|
|
5
5
|
import { stringifyNewsSchema } from './sdNews';
|
|
6
|
-
export const getStructuredDataSchemas = ({ title, description, nofollow, noindex, image, events, news, }) => {
|
|
6
|
+
export const getStructuredDataSchemas = ({ title, pathname, description, nofollow, noindex, image, events, news, }) => {
|
|
7
7
|
const { title: defaultTitle, description: defaultDescription, image: defaultImage, siteUrl, nofollow: defaultNofollow, noindex: defaultNoindex, } = siteMetadata();
|
|
8
8
|
const metadata = {
|
|
9
9
|
title: title || defaultTitle,
|
|
@@ -11,13 +11,13 @@ export const getStructuredDataSchemas = ({ title, description, nofollow, noindex
|
|
|
11
11
|
nofollow: nofollow || defaultNofollow,
|
|
12
12
|
noindex: noindex || defaultNoindex,
|
|
13
13
|
image: image || defaultImage,
|
|
14
|
-
url: `${siteUrl}${
|
|
14
|
+
url: `${siteUrl}${pathname || ''}`,
|
|
15
15
|
lang: 'en',
|
|
16
16
|
events: events,
|
|
17
17
|
news: news,
|
|
18
18
|
};
|
|
19
19
|
const schemas = [];
|
|
20
|
-
if (
|
|
20
|
+
if (pathname !== '') {
|
|
21
21
|
schemas.push(stringifyWebpageSchema({
|
|
22
22
|
name: metadata.title,
|
|
23
23
|
description: metadata.description,
|
|
@@ -23,3 +23,9 @@ export const Default = {
|
|
|
23
23
|
children: 'Heading',
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
|
+
export const LineClamp = {
|
|
27
|
+
render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG, underline: true, sx: { color: COLOR.PRIMARY } }, { children: size.label })), [p1, p2].map((content) => (_jsx(Paragraph, Object.assign({}, args, { size: size.size, clampLines: 2 }, { children: content }))))] })))) })),
|
|
28
|
+
args: {
|
|
29
|
+
children: 'Heading',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -11,6 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
13
13
|
import { getTypographyStyles, TYPOGRAPHY_TYPE, } from '../../../../theme/typography';
|
|
14
|
+
import { useTheme } from '../../../../theme';
|
|
15
|
+
import { multiplyRemSize } from '../../../../utils/misc';
|
|
14
16
|
export var PARAGRAPH_SIZE;
|
|
15
17
|
(function (PARAGRAPH_SIZE) {
|
|
16
18
|
PARAGRAPH_SIZE["SM"] = "sm";
|
|
@@ -23,7 +25,15 @@ const SIZE_TYPOGRAPHY_MAP = {
|
|
|
23
25
|
[PARAGRAPH_SIZE.LG]: TYPOGRAPHY_TYPE.PARAGRAPH_LARGE,
|
|
24
26
|
};
|
|
25
27
|
export const Paragraph = (_a) => {
|
|
26
|
-
var { size, typography: typographyParam, sx } = _a, rest = __rest(_a, ["size", "typography", "sx"]);
|
|
28
|
+
var { size, typography: typographyParam, sx, clampLines } = _a, rest = __rest(_a, ["size", "typography", "sx", "clampLines"]);
|
|
29
|
+
const theme = useTheme();
|
|
27
30
|
const typography = typographyParam || SIZE_TYPOGRAPHY_MAP[size || PARAGRAPH_SIZE.MD];
|
|
28
|
-
|
|
31
|
+
const typographyStyles = getTypographyStyles(typography);
|
|
32
|
+
const marginHeightMultiple = theme.lineHeights[typographyStyles.lineHeight] * 0.375;
|
|
33
|
+
const fontSize = theme.fontSizes[typographyStyles.fontSize];
|
|
34
|
+
const topMargin = multiplyRemSize({
|
|
35
|
+
size: fontSize,
|
|
36
|
+
multiple: marginHeightMultiple,
|
|
37
|
+
});
|
|
38
|
+
return (_jsx("div", Object.assign({ sx: Object.assign(Object.assign(Object.assign({}, getTypographyStyles(typography)), { display: clampLines ? '-webkit-box' : undefined, '-webkit-line-clamp': clampLines ? String(clampLines) : undefined, '-webkit-box-orient': 'vertical', overflow: clampLines ? 'hidden' : undefined, my: topMargin }), sx) }, rest)));
|
|
29
39
|
};
|
|
@@ -15,6 +15,7 @@ import { useTheme } from '../../../../theme';
|
|
|
15
15
|
import { COLOR, colors } from '../../../../theme/colors';
|
|
16
16
|
import { getTypographyStyles, } from '../../../../theme/typography';
|
|
17
17
|
import { useMediaQuery } from '../../../providers/media';
|
|
18
|
+
import { multiplyRemSize } from '../../../../utils/misc';
|
|
18
19
|
const ReadMoreLink = (props) => {
|
|
19
20
|
const bg = colors[props.bg || COLOR.BACKGROUND];
|
|
20
21
|
const color = colors[props.color || COLOR.ND_BLUE_LIGHT];
|
|
@@ -36,9 +37,11 @@ export const useLinesHeight = (args) => {
|
|
|
36
37
|
const styles = getTypographyStyles(args.typography);
|
|
37
38
|
const fontSize = styles.fontSize;
|
|
38
39
|
const fontSizeRem = theme.fontSizes[fontSize];
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const linesHeight = theme.lineHeights[styles.lineHeight] * args.lines;
|
|
41
|
+
return multiplyRemSize({
|
|
42
|
+
size: fontSizeRem,
|
|
43
|
+
multiple: linesHeight,
|
|
44
|
+
});
|
|
42
45
|
};
|
|
43
46
|
export const ReadMore = (_a) => {
|
|
44
47
|
var { typography, sx, role, lines, fixedHeight, children } = _a, rest = __rest(_a, ["typography", "sx", "role", "lines", "fixedHeight", "children"]);
|
package/dist/utils/misc.d.ts
CHANGED
|
@@ -12,3 +12,7 @@ export declare enum KEY_CODES {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const equals: (a: any, b: any) => boolean;
|
|
14
14
|
export declare function importedDefaultComponentShim<T>(component: T): T;
|
|
15
|
+
export declare const multiplyRemSize: (params: {
|
|
16
|
+
size: string;
|
|
17
|
+
multiple: number;
|
|
18
|
+
}) => string;
|
package/dist/utils/misc.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { multiplyRemSize } from './misc';
|
|
2
|
+
describe('multiplyRemSize', () => {
|
|
3
|
+
it('should multiply a rem size by a multiple', () => {
|
|
4
|
+
expect(multiplyRemSize({
|
|
5
|
+
size: '1rem',
|
|
6
|
+
multiple: 2,
|
|
7
|
+
})).toEqual('2rem');
|
|
8
|
+
expect(multiplyRemSize({
|
|
9
|
+
size: '1.5rem',
|
|
10
|
+
multiple: 2,
|
|
11
|
+
})).toEqual('3rem');
|
|
12
|
+
});
|
|
13
|
+
});
|