@bookjane2/bookjane-design-library 8.3.1 → 8.3.2
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/lib/components/BKJTypography/BKJTypography.d.ts +1 -2
- package/lib/components/BKJTypography/BKJTypography.d.ts.map +1 -1
- package/lib/components/BKJTypography/BKJTypography.js +4 -4
- package/lib/components/BKJTypography/BKJTypography.js.map +1 -1
- package/lib/components/BKJTypography/BKJTypography.stories.d.ts +7 -1
- package/lib/components/BKJTypography/BKJTypography.stories.d.ts.map +1 -1
- package/lib/components/BKJTypography/BKJTypography.stories.js +21 -1
- package/lib/components/BKJTypography/BKJTypography.stories.js.map +1 -1
- package/lib/components/BKJTypography/BKJTypography.styled.d.ts +2 -10
- package/lib/components/BKJTypography/BKJTypography.styled.d.ts.map +1 -1
- package/lib/components/BKJTypography/BKJTypography.styled.js +6 -23
- package/lib/components/BKJTypography/BKJTypography.styled.js.map +1 -1
- package/lib/components/BKJTypography/BKJTypography.test.d.ts +2 -0
- package/lib/components/BKJTypography/BKJTypography.test.d.ts.map +1 -0
- package/lib/components/BKJTypography/BKJTypography.test.js +89 -0
- package/lib/components/BKJTypography/BKJTypography.test.js.map +1 -0
- package/lib/components/BKJTypography/BKJTypography.types.d.ts +8 -5
- package/lib/components/BKJTypography/BKJTypography.types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
1
|
import { IBKJTypographyProps } from './BKJTypography.types.js';
|
|
3
|
-
export declare const BKJTypography:
|
|
2
|
+
export declare const BKJTypography: ({ variant, element, as: asProp, children, ...rest }: IBKJTypographyProps) => JSX.Element;
|
|
4
3
|
//# sourceMappingURL=BKJTypography.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BKJTypography.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,aAAa,GAAI,qDAM3B,mBAAmB,gBAOrB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
export const BKJTypography = ({ variant = 'Body', element = 'span', children, }) => {
|
|
4
|
-
const
|
|
5
|
-
return _jsx(
|
|
2
|
+
import { StyledTypography } from './BKJTypography.styled.js';
|
|
3
|
+
export const BKJTypography = ({ variant = 'Body', element = 'span', as: asProp, children, ...rest }) => {
|
|
4
|
+
const resolvedAs = asProp || element;
|
|
5
|
+
return (_jsx(StyledTypography, { as: resolvedAs, "$variant": variant, ...rest, children: children }));
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=BKJTypography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"BKJTypography.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,QAAQ,EACR,GAAG,IAAI,EACa,EAAE,EAAE;IACxB,MAAM,UAAU,GAAG,MAAM,IAAI,OAAO,CAAC;IACrC,OAAO,CACL,KAAC,gBAAgB,IAAC,EAAE,EAAE,UAAU,cAAY,OAAO,KAAM,IAAI,YAC1D,QAAQ,GACQ,CACpB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { StoryFn } from '@storybook/react';
|
|
1
2
|
import { IBKJTypographyProps } from './BKJTypography.types.js';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
title: string;
|
|
4
|
-
component:
|
|
5
|
+
component: ({ variant, element, as: asProp, children, ...rest }: IBKJTypographyProps) => JSX.Element;
|
|
5
6
|
argTypes: {
|
|
6
7
|
variant: {
|
|
7
8
|
name: string;
|
|
@@ -11,6 +12,10 @@ declare const _default: {
|
|
|
11
12
|
name: string;
|
|
12
13
|
options: string[];
|
|
13
14
|
};
|
|
15
|
+
as: {
|
|
16
|
+
name: string;
|
|
17
|
+
options: string[];
|
|
18
|
+
};
|
|
14
19
|
children: {
|
|
15
20
|
name: string;
|
|
16
21
|
type: string;
|
|
@@ -19,4 +24,5 @@ declare const _default: {
|
|
|
19
24
|
};
|
|
20
25
|
export default _default;
|
|
21
26
|
export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJTypographyProps>;
|
|
27
|
+
export declare const HeadingHierarchy: StoryFn;
|
|
22
28
|
//# sourceMappingURL=BKJTypography.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.stories.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BKJTypography.stories.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAE5D,wBA6CE;AAIF,eAAO,MAAM,OAAO,+GAAoB,CAAC;AAMzC,eAAO,MAAM,gBAAgB,EAAE,OAqB9B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { BKJTypography } from './index.js';
|
|
3
3
|
export default {
|
|
4
4
|
title: 'Basic Elements/BKJTypography',
|
|
@@ -24,6 +24,22 @@ export default {
|
|
|
24
24
|
name: 'Element',
|
|
25
25
|
options: ['h1', 'h2', 'h3', 'h4', 'span', 'b', 'p'],
|
|
26
26
|
},
|
|
27
|
+
as: {
|
|
28
|
+
name: 'As (Semantic Element)',
|
|
29
|
+
options: [
|
|
30
|
+
'h1',
|
|
31
|
+
'h2',
|
|
32
|
+
'h3',
|
|
33
|
+
'h4',
|
|
34
|
+
'h5',
|
|
35
|
+
'h6',
|
|
36
|
+
'p',
|
|
37
|
+
'span',
|
|
38
|
+
'label',
|
|
39
|
+
'legend',
|
|
40
|
+
'caption',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
27
43
|
children: {
|
|
28
44
|
name: 'Text',
|
|
29
45
|
type: 'string',
|
|
@@ -35,4 +51,8 @@ export const Default = Template.bind({});
|
|
|
35
51
|
Default.args = {
|
|
36
52
|
children: 'Lorem ipsum',
|
|
37
53
|
};
|
|
54
|
+
export const HeadingHierarchy = () => (_jsxs("div", { children: [_jsx(BKJTypography, { as: "h1", variant: "H1", children: "Heading Level 1 (h1)" }), _jsx(BKJTypography, { as: "h2", variant: "H2", children: "Heading Level 2 (h2)" }), _jsx(BKJTypography, { as: "h3", variant: "H3", children: "Heading Level 3 (h3)" }), _jsx(BKJTypography, { as: "h4", variant: "H4", children: "Heading Level 4 (h4)" }), _jsx(BKJTypography, { as: "h5", variant: "Bold", children: "Heading Level 5 (h5)" }), _jsx(BKJTypography, { as: "h6", variant: "CaptionBold", children: "Heading Level 6 (h6)" })] }));
|
|
55
|
+
HeadingHierarchy.parameters = {
|
|
56
|
+
controls: { disable: true },
|
|
57
|
+
};
|
|
38
58
|
//# sourceMappingURL=BKJTypography.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.stories.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAGlC,eAAe;IACb,KAAK,EAAE,8BAA8B;IACrC,SAAS,EAAE,aAAa;IACxB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE;gBACP,IAAI;gBACJ,IAAI;gBACJ,IAAI;gBACJ,IAAI;gBACJ,MAAM;gBACN,eAAe;gBACf,MAAM;gBACN,SAAS;gBACT,aAAa;gBACb,QAAQ;gBACR,UAAU;aACX;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;SACpD;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,QAAQ,GAAiC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAC,aAAa,OAAK,IAAI,GAAI,CAAC;AAErF,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEzC,OAAO,CAAC,IAAI,GAAG;IACb,QAAQ,EAAE,aAAa;CACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"BKJTypography.stories.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAGlC,eAAe;IACb,KAAK,EAAE,8BAA8B;IACrC,SAAS,EAAE,aAAa;IACxB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE;g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AC,IAAI,EAAC,OAAO,EAAC,MAAM,qCAErB,EAChB,KAAC,aAAa,IAAC,EAAE,EAAC,IAAI,EAAC,OAAO,EAAC,aAAa,qCAE5B,IACZ,CACP,CAAC;AAEF,gBAAgB,CAAC,UAAU,GAAG;IAC5B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;CAC5B,CAAC"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
h1: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, IBKJTypographyStyledElement>> & string;
|
|
4
|
-
h2: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, IBKJTypographyStyledElement>> & string;
|
|
5
|
-
h3: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, IBKJTypographyStyledElement>> & string;
|
|
6
|
-
h4: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, IBKJTypographyStyledElement>> & string;
|
|
7
|
-
span: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, IBKJTypographyStyledElement>> & string;
|
|
8
|
-
b: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, IBKJTypographyStyledElement>> & string;
|
|
9
|
-
p: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, IBKJTypographyStyledElement>> & string;
|
|
10
|
-
};
|
|
1
|
+
import { IStyledTypographyProps } from './BKJTypography.types.js';
|
|
2
|
+
export declare const StyledTypography: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, IStyledTypographyProps>> & string;
|
|
11
3
|
//# sourceMappingURL=BKJTypography.styled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.styled.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.styled.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"BKJTypography.styled.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.styled.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,eAAO,MAAM,gBAAgB,6PAK5B,CAAC"}
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`,
|
|
9
|
-
h3: styled.h3 `
|
|
10
|
-
${({ theme, $variant }) => theme.typography[$variant]};
|
|
11
|
-
`,
|
|
12
|
-
h4: styled.h4 `
|
|
13
|
-
${({ theme, $variant }) => theme.typography[$variant]};
|
|
14
|
-
`,
|
|
15
|
-
span: styled.span `
|
|
16
|
-
${({ theme, $variant }) => theme.typography[$variant]};
|
|
17
|
-
`,
|
|
18
|
-
b: styled.b `
|
|
19
|
-
${({ theme, $variant }) => theme.typography[$variant]};
|
|
20
|
-
`,
|
|
21
|
-
p: styled.p `
|
|
22
|
-
${({ theme, $variant }) => theme.typography[$variant]};
|
|
23
|
-
`,
|
|
24
|
-
};
|
|
2
|
+
export const StyledTypography = styled.span `
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
border: 0;
|
|
6
|
+
${({ theme, $variant }) => theme.typography[$variant]};
|
|
7
|
+
`;
|
|
25
8
|
//# sourceMappingURL=BKJTypography.styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.styled.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.styled.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"BKJTypography.styled.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.styled.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAwB;;;;IAI/D,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;CACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BKJTypography.test.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { axe, toHaveNoViolations } from 'jest-axe';
|
|
4
|
+
import { BKJTypography } from './BKJTypography.js';
|
|
5
|
+
import { BKJThemeProvider } from '../../providers/BKJThemeProvider/index.js';
|
|
6
|
+
expect.extend(toHaveNoViolations);
|
|
7
|
+
const renderWithTheme = (component) => {
|
|
8
|
+
return render(_jsx(BKJThemeProvider, { children: component }));
|
|
9
|
+
};
|
|
10
|
+
describe('US1: Semantic heading rendering', () => {
|
|
11
|
+
it('renders as h1 when as="h1" is passed', () => {
|
|
12
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h1", variant: "H1", children: "Heading 1" }));
|
|
13
|
+
expect(getByRole('heading', { level: 1 })).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
it('renders as h2 when as="h2" is passed', () => {
|
|
16
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h2", variant: "H2", children: "Heading 2" }));
|
|
17
|
+
expect(getByRole('heading', { level: 2 })).toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
it('renders as h3 when as="h3" is passed', () => {
|
|
20
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h3", variant: "H3", children: "Heading 3" }));
|
|
21
|
+
expect(getByRole('heading', { level: 3 })).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
it('renders as h4 when as="h4" is passed', () => {
|
|
24
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h4", variant: "H4", children: "Heading 4" }));
|
|
25
|
+
expect(getByRole('heading', { level: 4 })).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
it('renders as h5 when as="h5" is passed', () => {
|
|
28
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h5", variant: "Body", children: "Heading 5" }));
|
|
29
|
+
expect(getByRole('heading', { level: 5 })).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
it('renders as h6 when as="h6" is passed', () => {
|
|
32
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h6", variant: "Caption", children: "Heading 6" }));
|
|
33
|
+
expect(getByRole('heading', { level: 6 })).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
it('has no accessibility violations for heading hierarchy', async () => {
|
|
36
|
+
const { container } = renderWithTheme(_jsxs("main", { children: [_jsx(BKJTypography, { as: "h1", variant: "H1", children: "Main Title" }), _jsx(BKJTypography, { as: "h2", variant: "H2", children: "Section" }), _jsx(BKJTypography, { as: "h3", variant: "H3", children: "Subsection" }), _jsx(BKJTypography, { as: "h4", variant: "H4", children: "Detail" }), _jsx(BKJTypography, { as: "h5", variant: "Body", children: "Sub-detail" }), _jsx(BKJTypography, { as: "h6", variant: "Caption", children: "Fine print" })] }));
|
|
37
|
+
const results = await axe(container);
|
|
38
|
+
expect(results).toHaveNoViolations();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('US2: Backward-compatible default behavior', () => {
|
|
42
|
+
it('renders as span by default when no as or element prop is provided', () => {
|
|
43
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { children: "Default text" }));
|
|
44
|
+
expect(getByText('Default text').tagName).toBe('SPAN');
|
|
45
|
+
});
|
|
46
|
+
it('renders correct element when element prop is used without as', () => {
|
|
47
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { element: "h1", variant: "H1", children: "Element heading" }));
|
|
48
|
+
expect(getByRole('heading', { level: 1 })).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
it('renders as p when element="p" is used without as', () => {
|
|
51
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { element: "p", children: "Paragraph via element" }));
|
|
52
|
+
expect(getByText('Paragraph via element').tagName).toBe('P');
|
|
53
|
+
});
|
|
54
|
+
it('renders as b when element="b" is used without as', () => {
|
|
55
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { element: "b", variant: "Bold", children: "Bold via element" }));
|
|
56
|
+
expect(getByText('Bold via element').tagName).toBe('B');
|
|
57
|
+
});
|
|
58
|
+
it('as prop takes precedence over element when both provided', () => {
|
|
59
|
+
const { getByRole } = renderWithTheme(_jsx(BKJTypography, { as: "h2", element: "h3", variant: "H2", children: "Precedence test" }));
|
|
60
|
+
expect(getByRole('heading', { level: 2 })).toBeInTheDocument();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
describe('US3: Non-heading semantic elements', () => {
|
|
64
|
+
it('renders as p when as="p" is passed', () => {
|
|
65
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { as: "p", children: "Paragraph text" }));
|
|
66
|
+
expect(getByText('Paragraph text').tagName).toBe('P');
|
|
67
|
+
});
|
|
68
|
+
it('renders as label when as="label" is passed', () => {
|
|
69
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { as: "label", children: "Label text" }));
|
|
70
|
+
expect(getByText('Label text').tagName).toBe('LABEL');
|
|
71
|
+
});
|
|
72
|
+
it('renders as legend when as="legend" is passed', () => {
|
|
73
|
+
const { getByText } = renderWithTheme(_jsx("fieldset", { children: _jsx(BKJTypography, { as: "legend", children: "Legend text" }) }));
|
|
74
|
+
expect(getByText('Legend text').tagName).toBe('LEGEND');
|
|
75
|
+
});
|
|
76
|
+
it('renders as caption when as="caption" is passed', () => {
|
|
77
|
+
const { getByText } = renderWithTheme(_jsxs("table", { children: [_jsx(BKJTypography, { as: "caption", children: "Caption text" }), _jsx("tbody", { children: _jsx("tr", { children: _jsx("td", { children: "data" }) }) })] }));
|
|
78
|
+
expect(getByText('Caption text').tagName).toBe('CAPTION');
|
|
79
|
+
});
|
|
80
|
+
it('forwards htmlFor attribute when as="label"', () => {
|
|
81
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { as: "label", htmlFor: "email-input", children: "Email" }));
|
|
82
|
+
expect(getByText('Email')).toHaveAttribute('for', 'email-input');
|
|
83
|
+
});
|
|
84
|
+
it('renders as span when as="span" is explicitly passed', () => {
|
|
85
|
+
const { getByText } = renderWithTheme(_jsx(BKJTypography, { as: "span", children: "Explicit span" }));
|
|
86
|
+
expect(getByText('Explicit span').tagName).toBe('SPAN');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=BKJTypography.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BKJTypography.test.js","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.test.tsx"],"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a,IAAC,EAAE,EAAC,MAAM,8BAA8B,CACvD,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { Interpolation } from 'styled-components';
|
|
3
|
-
export interface
|
|
3
|
+
export interface IStyledTypographyProps {
|
|
4
4
|
$variant: BKJTypographyVariantType;
|
|
5
5
|
}
|
|
6
|
-
export interface IBKJTypographyProps {
|
|
7
|
-
variant
|
|
8
|
-
element
|
|
6
|
+
export interface IBKJTypographyProps extends HTMLAttributes<HTMLElement> {
|
|
7
|
+
variant?: BKJTypographyVariantType;
|
|
8
|
+
element?: BKJTypographyElementType;
|
|
9
|
+
as?: BKJTypographyAsType;
|
|
9
10
|
children: ReactNode;
|
|
11
|
+
[key: string]: unknown;
|
|
10
12
|
}
|
|
13
|
+
export type BKJTypographyAsType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'label' | 'legend' | 'caption';
|
|
11
14
|
export interface IBKJThemeTypography {
|
|
12
15
|
H1: Interpolation<any>;
|
|
13
16
|
H2: Interpolation<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BKJTypography.types.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BKJTypography.types.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTypography/BKJTypography.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,aAAa,EA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