@bootsmonday/corncob-design-language-react 0.1.0 → 0.2.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/CHANGELOG.md +11 -0
- package/dist-types/common/choice-name.d.ts +8 -0
- package/dist-types/common/field.d.ts +22 -0
- package/dist-types/common/form-item.d.ts +11 -0
- package/dist-types/components/badges/badge.d.ts +12 -0
- package/dist-types/components/button-bars/button-bar.d.ts +12 -0
- package/dist-types/components/buttons/button.d.ts +16 -0
- package/dist-types/components/checkboxes/checkbox-group.d.ts +13 -0
- package/dist-types/components/checkboxes/checkbox.d.ts +20 -0
- package/dist-types/components/expandables/expandable.d.ts +43 -0
- package/dist-types/components/footers/footer.d.ts +62 -0
- package/dist-types/components/headers/header.d.ts +72 -0
- package/dist-types/components/links/link.d.ts +22 -0
- package/dist-types/components/messages/message.d.ts +42 -0
- package/dist-types/components/modals/modal.d.ts +30 -0
- package/dist-types/components/panel-menus/panel-menu.d.ts +33 -0
- package/dist-types/components/panels/panel.d.ts +11 -0
- package/dist-types/components/popovers/popover.d.ts +35 -0
- package/dist-types/components/radio-buttons/radio-button-group.d.ts +13 -0
- package/dist-types/components/radio-buttons/radio-button.d.ts +18 -0
- package/dist-types/components/selects/select.d.ts +14 -0
- package/dist-types/components/sliders/slider.d.ts +7 -0
- package/dist-types/components/text-inputs/text-input.d.ts +6 -0
- package/dist-types/components/toasts/toast.d.ts +7 -0
- package/dist-types/components/toggles/toggle.d.ts +13 -0
- package/dist-types/components/tooltips/tooltip.d.ts +8 -0
- package/dist-types/custom-elements.d.ts +3 -0
- package/dist-types/index.d.ts +24 -0
- package/dist-types/utils/assign-ref.d.ts +7 -0
- package/dist-types/utils/class-names.d.ts +14 -0
- package/package.json +29 -8
- package/src/common/choice-name.js +7 -0
- package/src/common/field.jsx +17 -0
- package/src/common/form-item.jsx +5 -0
- package/src/components/badges/badge.jsx +5 -0
- package/src/components/button-bars/button-bar.jsx +5 -1
- package/src/components/buttons/button.jsx +5 -1
- package/src/components/checkboxes/checkbox-group.jsx +5 -0
- package/src/components/checkboxes/checkbox.jsx +5 -0
- package/src/components/expandables/expandable.jsx +20 -0
- package/src/components/footers/footer.jsx +30 -0
- package/src/components/headers/header.jsx +35 -0
- package/src/components/links/link.jsx +10 -0
- package/src/components/messages/message.jsx +20 -0
- package/src/components/modals/modal.jsx +15 -0
- package/src/components/panel-menus/panel-menu.jsx +15 -0
- package/src/components/panels/panel.jsx +5 -0
- package/src/components/popovers/popover.jsx +15 -0
- package/src/components/radio-buttons/radio-button-group.jsx +5 -0
- package/src/components/radio-buttons/radio-button.jsx +5 -0
- package/src/components/selects/select.jsx +10 -0
- package/src/components/sliders/slider.jsx +5 -0
- package/src/components/text-inputs/text-input.jsx +5 -0
- package/src/components/toasts/toast.jsx +5 -0
- package/src/components/toggles/toggle.jsx +10 -0
- package/src/components/tooltips/tooltip.jsx +5 -0
- package/src/custom-elements.d.ts +9 -0
- package/src/utils/assign-ref.js +6 -0
- package/src/utils/class-names.js +12 -0
- package/.changelog/README.md +0 -33
- package/jest.config.cjs +0 -17
- package/jest.setup.cjs +0 -19
- package/src/common/choice-name.test.js +0 -46
- package/src/common/field.test.js +0 -33
- package/src/common/form-item.test.js +0 -45
- package/src/components/badges/badge.stickersheet.jsx +0 -39
- package/src/components/badges/badge.test.js +0 -69
- package/src/components/button-bars/button-bar.stickersheet.jsx +0 -86
- package/src/components/button-bars/button-bar.test.js +0 -58
- package/src/components/buttons/button.stickersheet.jsx +0 -204
- package/src/components/buttons/button.test.js +0 -84
- package/src/components/checkboxes/checkbox.stickersheet.jsx +0 -53
- package/src/components/checkboxes/checkbox.test.js +0 -154
- package/src/components/expandables/expandable.stickersheet.jsx +0 -100
- package/src/components/expandables/expandable.test.js +0 -125
- package/src/components/footers/footer.stickersheet.jsx +0 -77
- package/src/components/footers/footer.test.js +0 -64
- package/src/components/headers/header.stickersheet.jsx +0 -63
- package/src/components/headers/header.test.js +0 -63
- package/src/components/links/link.stickersheet.jsx +0 -75
- package/src/components/links/link.test.js +0 -70
- package/src/components/messages/message.stickersheet.jsx +0 -96
- package/src/components/messages/message.test.js +0 -92
- package/src/components/modals/modal.stickersheet.jsx +0 -44
- package/src/components/modals/modal.test.js +0 -32
- package/src/components/panel-menus/panel-menu.stickersheet.jsx +0 -34
- package/src/components/panel-menus/panel-menu.test.js +0 -98
- package/src/components/panels/panel.stickersheet.jsx +0 -13
- package/src/components/panels/panel.test.js +0 -54
- package/src/components/popovers/popover.stickersheet.jsx +0 -236
- package/src/components/popovers/popover.test.js +0 -98
- package/src/components/radio-buttons/radio-button.stickersheet.jsx +0 -40
- package/src/components/radio-buttons/radio-button.test.js +0 -119
- package/src/components/selects/select.stickersheet.jsx +0 -34
- package/src/components/selects/select.test.js +0 -119
- package/src/components/sliders/slider.stickersheet.jsx +0 -29
- package/src/components/sliders/slider.test.js +0 -81
- package/src/components/text-inputs/text-input.stickersheet.jsx +0 -41
- package/src/components/text-inputs/text-input.test.js +0 -83
- package/src/components/toasts/toast.stickersheet.jsx +0 -54
- package/src/components/toasts/toast.test.js +0 -50
- package/src/components/toggles/toggle.stickersheet.jsx +0 -81
- package/src/components/toggles/toggle.test.js +0 -165
- package/src/components/tooltips/tooltip.stickersheet.jsx +0 -34
- package/src/components/tooltips/tooltip.test.js +0 -60
- package/src/stickersheets/badges.html +0 -31
- package/src/stickersheets/button-bars.html +0 -29
- package/src/stickersheets/buttons-standard.html +0 -33
- package/src/stickersheets/checkboxes.html +0 -32
- package/src/stickersheets/expandables.html +0 -29
- package/src/stickersheets/footers.html +0 -29
- package/src/stickersheets/headers.html +0 -29
- package/src/stickersheets/index.html +0 -56
- package/src/stickersheets/links.html +0 -29
- package/src/stickersheets/messages.html +0 -29
- package/src/stickersheets/modals.html +0 -29
- package/src/stickersheets/panel-menus.html +0 -29
- package/src/stickersheets/panels.html +0 -29
- package/src/stickersheets/popovers.html +0 -29
- package/src/stickersheets/radio-buttons.html +0 -32
- package/src/stickersheets/select.html +0 -31
- package/src/stickersheets/sliders.html +0 -31
- package/src/stickersheets/src/stickersheet-controls.html +0 -13
- package/src/stickersheets/src/stickersheet-header.html +0 -17
- package/src/stickersheets/src/stickersheet-react-header.html +0 -17
- package/src/stickersheets/src/stickersheet.css +0 -17
- package/src/stickersheets/src/stickersheet.js +0 -80
- package/src/stickersheets/text-inputs.html +0 -31
- package/src/stickersheets/toasts.html +0 -29
- package/src/stickersheets/toggles.html +0 -32
- package/src/stickersheets/tooltips.html +0 -29
- package/src/utils/assign-ref.test.js +0 -35
- package/src/utils/class-names.test.js +0 -21
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { createRef } from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { CornAccordion, CornExpandable, CornExpandableSummary, CornExpandableContent } from './expandable.jsx';
|
|
4
|
-
|
|
5
|
-
describe('CornExpandable', () => {
|
|
6
|
-
test('renders default expandable structure with corn-expandable host', () => {
|
|
7
|
-
const { container } = render(
|
|
8
|
-
<CornExpandable>
|
|
9
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
10
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
11
|
-
</CornExpandable>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
expect(container.querySelector('.corn-expandable')).toBeTruthy();
|
|
15
|
-
expect(container.querySelector('corn-expandable')).toBeTruthy();
|
|
16
|
-
expect(container.querySelector('details')).toBeTruthy();
|
|
17
|
-
expect(container.querySelector('details')).toHaveAttribute('slot', 'details');
|
|
18
|
-
expect(container.querySelector('summary.corn-expandable-button')).toHaveTextContent('Summary');
|
|
19
|
-
expect(container.querySelector('.corn-expandable--content')).toHaveTextContent('details');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('passes open prop to corn-expandable host', () => {
|
|
23
|
-
const { container } = render(
|
|
24
|
-
<CornExpandable open>
|
|
25
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
26
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
27
|
-
</CornExpandable>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const expandable = container.querySelector('corn-expandable');
|
|
31
|
-
const details = container.querySelector('details');
|
|
32
|
-
expect(expandable).toHaveAttribute('open');
|
|
33
|
-
expect(details.open).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('leaves open uncontrolled when the prop is omitted', () => {
|
|
37
|
-
const { container } = render(
|
|
38
|
-
<CornExpandable>
|
|
39
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
40
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
41
|
-
</CornExpandable>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
expect(container.querySelector('corn-expandable')).not.toHaveAttribute('open');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('closes when open changes to false', () => {
|
|
48
|
-
const { container, rerender } = render(
|
|
49
|
-
<CornExpandable open>
|
|
50
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
51
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
52
|
-
</CornExpandable>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
rerender(
|
|
56
|
-
<CornExpandable open={false}>
|
|
57
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
58
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
59
|
-
</CornExpandable>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const details = container.querySelector('details');
|
|
63
|
-
const content = details.querySelector('.corn-expandable--content');
|
|
64
|
-
expect(container.querySelector('corn-expandable')).not.toHaveAttribute('open');
|
|
65
|
-
expect(details).not.toHaveClass('corn-expandable--open');
|
|
66
|
-
|
|
67
|
-
const event = new Event('transitionend');
|
|
68
|
-
Object.defineProperty(event, 'propertyName', { value: 'grid-template-rows' });
|
|
69
|
-
content.dispatchEvent(event);
|
|
70
|
-
expect(details.open).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('supports nested and accordion wrappers', () => {
|
|
74
|
-
const { container } = render(
|
|
75
|
-
<>
|
|
76
|
-
<CornAccordion>
|
|
77
|
-
<CornExpandable>
|
|
78
|
-
<CornExpandableSummary>One</CornExpandableSummary>
|
|
79
|
-
<CornExpandableContent>A</CornExpandableContent>
|
|
80
|
-
</CornExpandable>
|
|
81
|
-
<CornExpandable>
|
|
82
|
-
<CornExpandableSummary>Two</CornExpandableSummary>
|
|
83
|
-
<CornExpandableContent>B</CornExpandableContent>
|
|
84
|
-
</CornExpandable>
|
|
85
|
-
</CornAccordion>
|
|
86
|
-
<CornExpandable className="corn-tree-view">
|
|
87
|
-
<CornExpandableSummary>Parent</CornExpandableSummary>
|
|
88
|
-
<CornExpandableContent>
|
|
89
|
-
<CornExpandable className="corn-tree-view">
|
|
90
|
-
<CornExpandableSummary>Child</CornExpandableSummary>
|
|
91
|
-
<CornExpandableContent>Child details</CornExpandableContent>
|
|
92
|
-
</CornExpandable>
|
|
93
|
-
</CornExpandableContent>
|
|
94
|
-
</CornExpandable>
|
|
95
|
-
</>
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
expect(container.querySelector('.corn-accordion')).toBeTruthy();
|
|
99
|
-
expect(screen.getByText('Child details')).toBeTruthy();
|
|
100
|
-
expect(container.querySelectorAll('.corn-tree-view')).toHaveLength(2);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('forwards ref to the corn-expandable host', () => {
|
|
104
|
-
const ref = createRef();
|
|
105
|
-
render(
|
|
106
|
-
<CornExpandable ref={ref}>
|
|
107
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
108
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
109
|
-
</CornExpandable>
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
expect(ref.current.tagName).toBe('CORN-EXPANDABLE');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('passes name to details for accordion grouping', () => {
|
|
116
|
-
const { container } = render(
|
|
117
|
-
<CornExpandable name="corn-single">
|
|
118
|
-
<CornExpandableSummary>Summary</CornExpandableSummary>
|
|
119
|
-
<CornExpandableContent>details</CornExpandableContent>
|
|
120
|
-
</CornExpandable>
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
expect(container.querySelector('details')).toHaveAttribute('name', 'corn-single');
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import { CornFooter, CornFooterIntro, CornFooterContent, CornFooterSection, CornFooterSocial, CornFooterCopyright, CornLink } from '../../index.js';
|
|
4
|
-
|
|
5
|
-
const NAV_SECTIONS = [
|
|
6
|
-
{
|
|
7
|
-
title: 'Company',
|
|
8
|
-
links: ['About Us', 'Careers', 'Press'],
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
title: 'Support',
|
|
12
|
-
links: ['Contact Us', 'FAQs', 'Help Center'],
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
title: 'Legal',
|
|
16
|
-
links: ['Privacy Policy', 'Terms of Service', 'Cookie Policy'],
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const SOCIAL_LINKS = [
|
|
21
|
-
{ label: 'X', icon: 'twitter-x' },
|
|
22
|
-
{ label: 'Instagram', icon: 'instagram' },
|
|
23
|
-
{ label: 'LinkedIn', icon: 'linkedin' },
|
|
24
|
-
{ label: 'GitHub', icon: 'github' },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
function SocialIcon({ icon }) {
|
|
28
|
-
return (
|
|
29
|
-
<svg xmlns="http://www.w3.org/2000/svg" className="corn-icon" aria-hidden="true">
|
|
30
|
-
<use href={`/node_modules/bootstrap-icons/bootstrap-icons.svg#${icon}`}></use>
|
|
31
|
-
</svg>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function DemoRouterLink({ to, children, ...props }) {
|
|
36
|
-
return (
|
|
37
|
-
<a {...props} href={to} data-router-link="true">
|
|
38
|
-
{children}
|
|
39
|
-
</a>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const root = ReactDOM.createRoot(document.getElementById('test-stickersheet'));
|
|
44
|
-
root.render(
|
|
45
|
-
<div className="footer-demo">
|
|
46
|
-
<h2>Corn Footer</h2>
|
|
47
|
-
<CornFooter>
|
|
48
|
-
<CornFooterIntro>The footer is the last section of a page, and typically contains information about the company, links to important pages, and social media links.</CornFooterIntro>
|
|
49
|
-
|
|
50
|
-
<CornFooterContent>
|
|
51
|
-
{NAV_SECTIONS.map((section) => (
|
|
52
|
-
<CornFooterSection key={section.title} title={section.title}>
|
|
53
|
-
<ul>
|
|
54
|
-
{section.links.map((label) => (
|
|
55
|
-
<li key={label}>
|
|
56
|
-
<CornLink as={DemoRouterLink} to="#" className="corn-link">
|
|
57
|
-
{label}
|
|
58
|
-
</CornLink>
|
|
59
|
-
</li>
|
|
60
|
-
))}
|
|
61
|
-
</ul>
|
|
62
|
-
</CornFooterSection>
|
|
63
|
-
))}
|
|
64
|
-
</CornFooterContent>
|
|
65
|
-
|
|
66
|
-
<CornFooterSocial>
|
|
67
|
-
{SOCIAL_LINKS.map((item) => (
|
|
68
|
-
<CornLink key={item.label} href="#" aria-label={item.label}>
|
|
69
|
-
<SocialIcon icon={item.icon} />
|
|
70
|
-
</CornLink>
|
|
71
|
-
))}
|
|
72
|
-
</CornFooterSocial>
|
|
73
|
-
|
|
74
|
-
<CornFooterCopyright>© 2026 Your Company. All rights reserved.</CornFooterCopyright>
|
|
75
|
-
</CornFooter>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { createRef } from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { CornFooter, CornFooterIntro, CornFooterContent, CornFooterSection, CornFooterSocial, CornFooterCopyright } from './footer.jsx';
|
|
4
|
-
|
|
5
|
-
describe('CornFooter', () => {
|
|
6
|
-
test('renders canonical footer structure classes', () => {
|
|
7
|
-
const { container } = render(
|
|
8
|
-
<CornFooter>
|
|
9
|
-
<CornFooterIntro>Intro</CornFooterIntro>
|
|
10
|
-
<CornFooterContent>
|
|
11
|
-
<CornFooterSection title="Company">
|
|
12
|
-
<ul>
|
|
13
|
-
<li>Item</li>
|
|
14
|
-
</ul>
|
|
15
|
-
</CornFooterSection>
|
|
16
|
-
</CornFooterContent>
|
|
17
|
-
<CornFooterSocial>
|
|
18
|
-
<a href="#" className="corn-link" aria-label="X">
|
|
19
|
-
X
|
|
20
|
-
</a>
|
|
21
|
-
</CornFooterSocial>
|
|
22
|
-
<CornFooterCopyright>Copyright</CornFooterCopyright>
|
|
23
|
-
</CornFooter>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
expect(container.querySelector('footer.corn-footer')).toBeTruthy();
|
|
27
|
-
expect(container.querySelector('.corn-footer--intro')).toHaveTextContent('Intro');
|
|
28
|
-
expect(container.querySelector('.corn-footer--content')).toBeTruthy();
|
|
29
|
-
expect(container.querySelector('.corn-footer--content--section h3')).toHaveTextContent('Company');
|
|
30
|
-
expect(container.querySelector('.corn-footer--social')).toBeTruthy();
|
|
31
|
-
expect(container.querySelector('.corn-footer--copyright')).toHaveTextContent('Copyright');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('supports custom section host element', () => {
|
|
35
|
-
const { container } = render(
|
|
36
|
-
<CornFooter>
|
|
37
|
-
<CornFooterContent>
|
|
38
|
-
<CornFooterSection as="section" title="Support" data-testid="support-section">
|
|
39
|
-
<ul>
|
|
40
|
-
<li>FAQs</li>
|
|
41
|
-
</ul>
|
|
42
|
-
</CornFooterSection>
|
|
43
|
-
</CornFooterContent>
|
|
44
|
-
</CornFooter>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const section = screen.getByTestId('support-section');
|
|
48
|
-
expect(section.tagName).toBe('SECTION');
|
|
49
|
-
expect(section).toHaveClass('corn-footer--content--section');
|
|
50
|
-
expect(container.querySelector('h3')).toHaveTextContent('Support');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('forwards ref to footer root', () => {
|
|
54
|
-
const ref = createRef();
|
|
55
|
-
|
|
56
|
-
render(
|
|
57
|
-
<CornFooter ref={ref}>
|
|
58
|
-
<CornFooterCopyright>Copy</CornFooterCopyright>
|
|
59
|
-
</CornFooter>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
expect(ref.current).toBe(screen.getByText('Copy').closest('.corn-footer'));
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import { CornButton, CornButtonBar, CornHeader, CornHeaderActions, CornHeaderCompany, CornHeaderCompanyLogo, CornHeaderCompanyName, CornHeaderNav, CornHeaderTitle } from '../../index.js';
|
|
4
|
-
|
|
5
|
-
const HEADER_LINKS = ['Link 1', 'Link 2', 'Link 3', 'Link 4', 'Link 5', 'Link 6', 'Link 7', 'Link 8', 'Link 9'];
|
|
6
|
-
|
|
7
|
-
function HeaderSettingsIcon() {
|
|
8
|
-
return (
|
|
9
|
-
<svg xmlns="http://www.w3.org/2000/svg" className="corn-icon" aria-hidden="true">
|
|
10
|
-
<use href="/node_modules/bootstrap-icons/bootstrap-icons.svg#gear"></use>
|
|
11
|
-
</svg>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function HeaderGithubIcon() {
|
|
16
|
-
return (
|
|
17
|
-
<svg xmlns="http://www.w3.org/2000/svg" className="corn-icon" aria-hidden="true">
|
|
18
|
-
<use href="/node_modules/bootstrap-icons/bootstrap-icons.svg#github"></use>
|
|
19
|
-
</svg>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const root = ReactDOM.createRoot(document.getElementById('test-stickersheet'));
|
|
24
|
-
root.render(
|
|
25
|
-
<div className="header-demo">
|
|
26
|
-
<CornHeader>
|
|
27
|
-
<CornHeaderCompany>
|
|
28
|
-
<CornHeaderCompanyLogo>
|
|
29
|
-
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
30
|
-
<use href="/corncob-design-language.svg"></use>
|
|
31
|
-
</svg>
|
|
32
|
-
</CornHeaderCompanyLogo>
|
|
33
|
-
<CornHeaderCompanyName>Corncob</CornHeaderCompanyName>
|
|
34
|
-
</CornHeaderCompany>
|
|
35
|
-
|
|
36
|
-
<CornHeaderTitle>Title Page</CornHeaderTitle>
|
|
37
|
-
|
|
38
|
-
<CornHeaderNav>
|
|
39
|
-
<CornButtonBar overflowLabel="More">
|
|
40
|
-
{HEADER_LINKS.map((label) => (
|
|
41
|
-
<CornButton key={label} as="a" href="#" size="sm">
|
|
42
|
-
{label}
|
|
43
|
-
</CornButton>
|
|
44
|
-
))}
|
|
45
|
-
</CornButtonBar>
|
|
46
|
-
</CornHeaderNav>
|
|
47
|
-
|
|
48
|
-
<CornHeaderActions>
|
|
49
|
-
<CornButton size="xs" type="button">
|
|
50
|
-
Action 1
|
|
51
|
-
</CornButton>
|
|
52
|
-
|
|
53
|
-
<CornButton size="xs" icon type="button" aria-label="Settings">
|
|
54
|
-
<HeaderSettingsIcon />
|
|
55
|
-
</CornButton>
|
|
56
|
-
|
|
57
|
-
<CornButton as="a" href="#" size="xs" icon aria-label="GitHub">
|
|
58
|
-
<HeaderGithubIcon />
|
|
59
|
-
</CornButton>
|
|
60
|
-
</CornHeaderActions>
|
|
61
|
-
</CornHeader>
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createRef } from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { CornHeader, CornHeaderActions, CornHeaderCompany, CornHeaderCompanyLogo, CornHeaderCompanyName, CornHeaderNav, CornHeaderTitle } from './header.jsx';
|
|
4
|
-
|
|
5
|
-
describe('CornHeader', () => {
|
|
6
|
-
test('renders canonical header structure classes', () => {
|
|
7
|
-
const { container } = render(
|
|
8
|
-
<CornHeader>
|
|
9
|
-
<CornHeaderCompany>
|
|
10
|
-
<CornHeaderCompanyLogo>
|
|
11
|
-
<svg aria-hidden="true"></svg>
|
|
12
|
-
</CornHeaderCompanyLogo>
|
|
13
|
-
<CornHeaderCompanyName>Corncob</CornHeaderCompanyName>
|
|
14
|
-
</CornHeaderCompany>
|
|
15
|
-
<CornHeaderTitle>Title Page</CornHeaderTitle>
|
|
16
|
-
<CornHeaderNav>
|
|
17
|
-
<a href="#" className="corn-button corn-button--sm">
|
|
18
|
-
Link 1
|
|
19
|
-
</a>
|
|
20
|
-
</CornHeaderNav>
|
|
21
|
-
<CornHeaderActions>
|
|
22
|
-
<button className="corn-button corn-button--xs" type="button">
|
|
23
|
-
Action 1
|
|
24
|
-
</button>
|
|
25
|
-
</CornHeaderActions>
|
|
26
|
-
</CornHeader>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
expect(container.querySelector('header.corn-header')).toBeTruthy();
|
|
30
|
-
expect(container.querySelector('.corn-company')).toBeTruthy();
|
|
31
|
-
expect(container.querySelector('.corn-company--logo svg')).toBeTruthy();
|
|
32
|
-
expect(container.querySelector('.corn-company--name')).toHaveTextContent('Corncob');
|
|
33
|
-
expect(container.querySelector('.corn-header--title')).toHaveTextContent('Title Page');
|
|
34
|
-
expect(container.querySelector('nav.corn-header--nav')).toBeTruthy();
|
|
35
|
-
expect(container.querySelector('.corn-header--actions')).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('supports custom heading element for header title', () => {
|
|
39
|
-
render(
|
|
40
|
-
<CornHeader>
|
|
41
|
-
<CornHeaderTitle as="h1" data-testid="title">
|
|
42
|
-
Title Page
|
|
43
|
-
</CornHeaderTitle>
|
|
44
|
-
</CornHeader>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const title = screen.getByTestId('title');
|
|
48
|
-
expect(title.tagName).toBe('H1');
|
|
49
|
-
expect(title).toHaveClass('corn-header--title');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('forwards ref to header root element', () => {
|
|
53
|
-
const ref = createRef();
|
|
54
|
-
|
|
55
|
-
render(
|
|
56
|
-
<CornHeader ref={ref}>
|
|
57
|
-
<CornHeaderTitle>Title Page</CornHeaderTitle>
|
|
58
|
-
</CornHeader>
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
expect(ref.current).toBe(screen.getByText('Title Page').closest('.corn-header'));
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import { CornLink, CornLinkList } from '../../index.js';
|
|
4
|
-
|
|
5
|
-
function DemoRouterLink({ to, children, ...props }) {
|
|
6
|
-
return (
|
|
7
|
-
<a {...props} href={to} data-router-link="true">
|
|
8
|
-
{children}
|
|
9
|
-
</a>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const root = ReactDOM.createRoot(document.getElementById('test-stickersheet'));
|
|
14
|
-
root.render(
|
|
15
|
-
<>
|
|
16
|
-
<h1>Link Stickersheet</h1>
|
|
17
|
-
|
|
18
|
-
<hr />
|
|
19
|
-
|
|
20
|
-
<section id="links">
|
|
21
|
-
<h2>Links</h2>
|
|
22
|
-
<div>
|
|
23
|
-
<CornLink href="#example-link">Forgot Username or Password?</CornLink>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<div>
|
|
27
|
-
<CornLink href="#example-link">Create a new account</CornLink>
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
<div>
|
|
31
|
-
<CornLink as={DemoRouterLink} to="/account/recover">
|
|
32
|
-
React Router style link
|
|
33
|
-
</CornLink>
|
|
34
|
-
</div>
|
|
35
|
-
</section>
|
|
36
|
-
|
|
37
|
-
<hr />
|
|
38
|
-
|
|
39
|
-
<section id="inline-links">
|
|
40
|
-
<h2>Inline Links</h2>
|
|
41
|
-
<p>
|
|
42
|
-
The language includes over{' '}
|
|
43
|
-
<CornLink underline href="#example-link">
|
|
44
|
-
40 coded user interface elements
|
|
45
|
-
</CornLink>
|
|
46
|
-
, including buttons, form controls, navigation, modals and more, as well as several{' '}
|
|
47
|
-
<CornLink underline href="#example-link">
|
|
48
|
-
page templates
|
|
49
|
-
</CornLink>
|
|
50
|
-
. We're continuing to release{' '}
|
|
51
|
-
<CornLink underline as={DemoRouterLink} to="/components/new">
|
|
52
|
-
additional components
|
|
53
|
-
</CornLink>{' '}
|
|
54
|
-
to meet the needs of our diverse product suite.
|
|
55
|
-
</p>
|
|
56
|
-
</section>
|
|
57
|
-
|
|
58
|
-
<section id="link-lists">
|
|
59
|
-
<h2>Link Lists</h2>
|
|
60
|
-
<CornLinkList>
|
|
61
|
-
<li>
|
|
62
|
-
<CornLink href="#">Link list item one</CornLink>
|
|
63
|
-
</li>
|
|
64
|
-
<li>
|
|
65
|
-
<CornLink as={DemoRouterLink} to="/docs/two">
|
|
66
|
-
Link list item two
|
|
67
|
-
</CornLink>
|
|
68
|
-
</li>
|
|
69
|
-
<li>
|
|
70
|
-
<CornLink href="#">Link list item three</CornLink>
|
|
71
|
-
</li>
|
|
72
|
-
</CornLinkList>
|
|
73
|
-
</section>
|
|
74
|
-
</>
|
|
75
|
-
);
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createRef } from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { CornLink, CornLinkList } from './link.jsx';
|
|
4
|
-
|
|
5
|
-
function RouterLinkStub({ to, children, ...props }) {
|
|
6
|
-
return (
|
|
7
|
-
<a {...props} href={to} data-router="stub">
|
|
8
|
-
{children}
|
|
9
|
-
</a>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe('CornLink', () => {
|
|
14
|
-
test('renders an anchor with corn-link by default', () => {
|
|
15
|
-
render(<CornLink href="#a">Forgot Password?</CornLink>);
|
|
16
|
-
|
|
17
|
-
const link = screen.getByRole('link', { name: 'Forgot Password?' });
|
|
18
|
-
expect(link).toHaveClass('corn-link');
|
|
19
|
-
expect(link).toHaveAttribute('href', '#a');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('renders underline variant class', () => {
|
|
23
|
-
render(
|
|
24
|
-
<CornLink underline href="#a">
|
|
25
|
-
Underline Link
|
|
26
|
-
</CornLink>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
expect(screen.getByRole('link', { name: 'Underline Link' })).toHaveClass('corn-link', 'corn-link--underline');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('supports router-style link components via as prop', () => {
|
|
33
|
-
render(
|
|
34
|
-
<CornLink as={RouterLinkStub} to="/settings">
|
|
35
|
-
Settings
|
|
36
|
-
</CornLink>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const link = screen.getByRole('link', { name: 'Settings' });
|
|
40
|
-
expect(link).toHaveClass('corn-link');
|
|
41
|
-
expect(link).toHaveAttribute('href', '/settings');
|
|
42
|
-
expect(link).toHaveAttribute('data-router', 'stub');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('forwards a ref to the host element', () => {
|
|
46
|
-
const ref = createRef();
|
|
47
|
-
render(
|
|
48
|
-
<CornLink ref={ref} href="#a">
|
|
49
|
-
Docs
|
|
50
|
-
</CornLink>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
expect(ref.current).toBe(screen.getByRole('link', { name: 'Docs' }));
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('CornLinkList', () => {
|
|
58
|
-
test('renders a ul with corn-link-list class', () => {
|
|
59
|
-
const { container } = render(
|
|
60
|
-
<CornLinkList>
|
|
61
|
-
<li>
|
|
62
|
-
<CornLink href="#a">One</CornLink>
|
|
63
|
-
</li>
|
|
64
|
-
</CornLinkList>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
expect(container.querySelector('ul')).toHaveClass('corn-link-list');
|
|
68
|
-
expect(screen.getByRole('link', { name: 'One' })).toHaveClass('corn-link');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import { CornMessage, CornMessageContent, CornMessageStatus, CornMessageTitle } from '../../index.js';
|
|
4
|
-
|
|
5
|
-
function MessageStatusIcon({ icon }) {
|
|
6
|
-
return (
|
|
7
|
-
<svg xmlns="http://www.w3.org/2000/svg" className="corn-icon" aria-hidden="true">
|
|
8
|
-
<use href={`/node_modules/bootstrap-icons/bootstrap-icons.svg#${icon}`}></use>
|
|
9
|
-
</svg>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const root = ReactDOM.createRoot(document.getElementById('test-stickersheet'));
|
|
14
|
-
root.render(
|
|
15
|
-
<>
|
|
16
|
-
<h2>CornMessage API Coverage</h2>
|
|
17
|
-
|
|
18
|
-
<h3>variant</h3>
|
|
19
|
-
<CornMessage variant="success">
|
|
20
|
-
<CornMessageStatus>
|
|
21
|
-
<MessageStatusIcon icon="check-lg" />
|
|
22
|
-
</CornMessageStatus>
|
|
23
|
-
<CornMessageContent>
|
|
24
|
-
<CornMessageTitle>Success Message</CornMessageTitle>
|
|
25
|
-
<p>This is a success message.</p>
|
|
26
|
-
</CornMessageContent>
|
|
27
|
-
</CornMessage>
|
|
28
|
-
<CornMessage variant="warning">
|
|
29
|
-
<CornMessageStatus>
|
|
30
|
-
<MessageStatusIcon icon="exclamation-triangle" />
|
|
31
|
-
</CornMessageStatus>
|
|
32
|
-
<CornMessageContent>
|
|
33
|
-
<CornMessageTitle>Warning Message</CornMessageTitle>
|
|
34
|
-
<p>This is a warning message.</p>
|
|
35
|
-
</CornMessageContent>
|
|
36
|
-
</CornMessage>
|
|
37
|
-
<CornMessage variant="error">
|
|
38
|
-
<CornMessageStatus>
|
|
39
|
-
<MessageStatusIcon icon="x-lg" />
|
|
40
|
-
</CornMessageStatus>
|
|
41
|
-
<CornMessageContent>
|
|
42
|
-
<CornMessageTitle>Error Message</CornMessageTitle>
|
|
43
|
-
<p>This is an error message.</p>
|
|
44
|
-
</CornMessageContent>
|
|
45
|
-
</CornMessage>
|
|
46
|
-
<CornMessage variant="info">
|
|
47
|
-
<CornMessageStatus>
|
|
48
|
-
<MessageStatusIcon icon="info-lg" />
|
|
49
|
-
</CornMessageStatus>
|
|
50
|
-
<CornMessageContent>
|
|
51
|
-
<CornMessageTitle>Info Message</CornMessageTitle>
|
|
52
|
-
<p>This is an info message.</p>
|
|
53
|
-
</CornMessageContent>
|
|
54
|
-
</CornMessage>
|
|
55
|
-
|
|
56
|
-
<h3>default variant (info)</h3>
|
|
57
|
-
<CornMessage>
|
|
58
|
-
<CornMessageStatus>
|
|
59
|
-
<MessageStatusIcon icon="info-lg" />
|
|
60
|
-
</CornMessageStatus>
|
|
61
|
-
<CornMessageContent>
|
|
62
|
-
<CornMessageTitle>Default Variant Message</CornMessageTitle>
|
|
63
|
-
<p>When variant is omitted, CornMessage defaults to info.</p>
|
|
64
|
-
</CornMessageContent>
|
|
65
|
-
</CornMessage>
|
|
66
|
-
|
|
67
|
-
<h3>children</h3>
|
|
68
|
-
<CornMessage variant="success">
|
|
69
|
-
<CornMessageContent>
|
|
70
|
-
<CornMessageTitle>Status omitted</CornMessageTitle>
|
|
71
|
-
<p>No status block is rendered unless you include CornMessageStatus.</p>
|
|
72
|
-
</CornMessageContent>
|
|
73
|
-
</CornMessage>
|
|
74
|
-
|
|
75
|
-
<h3>CornMessageTitle as</h3>
|
|
76
|
-
<CornMessage variant="warning">
|
|
77
|
-
<CornMessageStatus>
|
|
78
|
-
<MessageStatusIcon icon="exclamation-triangle" />
|
|
79
|
-
</CornMessageStatus>
|
|
80
|
-
<CornMessageContent>
|
|
81
|
-
<CornMessageTitle as="p">Title rendered as paragraph</CornMessageTitle>
|
|
82
|
-
</CornMessageContent>
|
|
83
|
-
</CornMessage>
|
|
84
|
-
|
|
85
|
-
<h3>className + prop passthrough</h3>
|
|
86
|
-
<CornMessage variant="info" className="api-coverage-custom-message" id="api-coverage-message" data-testid="api-coverage-message">
|
|
87
|
-
<CornMessageStatus>
|
|
88
|
-
<MessageStatusIcon icon="info-lg" />
|
|
89
|
-
</CornMessageStatus>
|
|
90
|
-
<CornMessageContent>
|
|
91
|
-
<CornMessageTitle>Custom class and attributes</CornMessageTitle>
|
|
92
|
-
<p>Supports className merging and standard div attributes.</p>
|
|
93
|
-
</CornMessageContent>
|
|
94
|
-
</CornMessage>
|
|
95
|
-
</>
|
|
96
|
-
);
|