@node-core/ui-components 1.0.1-31c31c9e3d61d76150eae83e7d2385b86cfdef71 → 1.0.1-49d65845ae6ff8d53a36f08f2f6353edc12d9b2f

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.
Files changed (26) hide show
  1. package/Common/AlertBox/index.module.css +7 -0
  2. package/Common/AlertBox/index.stories.tsx +23 -0
  3. package/Common/AvatarGroup/index.module.css +4 -8
  4. package/Common/AvatarGroup/index.tsx +1 -5
  5. package/Common/BaseButton/index.module.css +4 -1
  6. package/Common/ChangeHistory/index.module.css +83 -0
  7. package/Common/ChangeHistory/index.stories.tsx +130 -0
  8. package/Common/ChangeHistory/index.tsx +67 -0
  9. package/Containers/DocSideBar/index.tsx +0 -0
  10. package/{Common/ProgressionSidebar/ProgressionSidebarIcon → Containers/Sidebar/ProgressionIcon}/index.tsx +2 -2
  11. package/Containers/Sidebar/SidebarGroup/index.module.css +54 -16
  12. package/Containers/Sidebar/SidebarGroup/index.tsx +21 -2
  13. package/Containers/Sidebar/SidebarItem/index.module.css +39 -18
  14. package/Containers/Sidebar/SidebarItem/index.tsx +25 -8
  15. package/Containers/Sidebar/index.module.css +5 -6
  16. package/Containers/Sidebar/index.stories.tsx +78 -74
  17. package/Containers/Sidebar/index.tsx +17 -5
  18. package/Icons/Logos/Nodejs.tsx +201 -17
  19. package/package.json +13 -13
  20. package/Common/ProgressionSidebar/ProgressionSidebarGroup/index.module.css +0 -47
  21. package/Common/ProgressionSidebar/ProgressionSidebarGroup/index.tsx +0 -35
  22. package/Common/ProgressionSidebar/ProgressionSidebarItem/index.module.css +0 -39
  23. package/Common/ProgressionSidebar/ProgressionSidebarItem/index.tsx +0 -32
  24. package/Common/ProgressionSidebar/index.module.css +0 -30
  25. package/Common/ProgressionSidebar/index.stories.tsx +0 -79
  26. package/Common/ProgressionSidebar/index.tsx +0 -59
@@ -73,4 +73,11 @@
73
73
  @apply bg-danger-700;
74
74
  }
75
75
  }
76
+
77
+ code {
78
+ /* Ignore the styles from `markdown.css` */
79
+ all: unset;
80
+
81
+ @apply font-ibm-plex-mono;
82
+ }
76
83
  }
@@ -6,6 +6,12 @@ import AlertBox from '#ui/Common/AlertBox';
6
6
  type Story = StoryObj<typeof AlertBox>;
7
7
  type Meta = MetaObj<typeof AlertBox>;
8
8
 
9
+ const withMain = (args: React.ComponentProps<typeof AlertBox>) => (
10
+ <main>
11
+ <AlertBox {...args} />
12
+ </main>
13
+ );
14
+
9
15
  export const Info: Story = {
10
16
  args: {
11
17
  level: 'info',
@@ -46,6 +52,23 @@ export const Danger: Story = {
46
52
  },
47
53
  };
48
54
 
55
+ export const InMarkdown: Story = {
56
+ args: {
57
+ level: 'danger',
58
+ title: '0',
59
+ children: (
60
+ <>
61
+ In a markdown component, <code>Code renders correctly,</code>{' '}
62
+ <a href="#">
63
+ <code>even when in a link</code>
64
+ </a>
65
+ </>
66
+ ),
67
+ size: 'default',
68
+ },
69
+ render: withMain,
70
+ };
71
+
49
72
  export const WithIcon: Story = {
50
73
  args: {
51
74
  level: 'info',
@@ -4,22 +4,18 @@
4
4
  @apply flex
5
5
  flex-wrap
6
6
  items-center;
7
-
8
- &:not(.expandable) {
9
- > span {
10
- @apply ml-0;
11
- }
12
- }
13
7
  }
14
8
 
15
9
  .small {
16
10
  > span {
17
- @apply -ml-2;
11
+ @apply -ml-2
12
+ first:ml-0;
18
13
  }
19
14
  }
20
15
 
21
16
  .medium {
22
17
  > span {
23
- @apply -ml-2.5;
18
+ @apply -ml-2.5
19
+ first:ml-0;
24
20
  }
25
21
  }
@@ -42,11 +42,7 @@ const AvatarGroup: FC<AvatarGroupProps> = ({
42
42
  : undefined;
43
43
 
44
44
  return (
45
- <div
46
- className={classNames(styles.avatarGroup, styles[size], {
47
- [styles.expandable]: avatars.length > limit,
48
- })}
49
- >
45
+ <div className={classNames(styles.avatarGroup, styles[size])}>
50
46
  {renderAvatars.map(avatar => (
51
47
  <Tooltip
52
48
  key={avatar.nickname}
@@ -73,11 +73,14 @@
73
73
 
74
74
  &.secondary {
75
75
  @apply rounded-lg
76
+ border
77
+ border-neutral-200
76
78
  text-neutral-800
79
+ dark:border-neutral-900
77
80
  dark:text-neutral-200;
78
81
 
79
82
  &:hover:not([aria-disabled='true']) {
80
- @apply bg-neutral-100
83
+ @apply bg-neutral-200
81
84
  text-neutral-800
82
85
  dark:bg-neutral-900
83
86
  dark:text-neutral-200;
@@ -0,0 +1,83 @@
1
+ @reference "../../styles/index.css";
2
+
3
+ .summary {
4
+ @apply outline-hidden
5
+ flex
6
+ h-9
7
+ cursor-pointer
8
+ select-none
9
+ items-center
10
+ gap-2
11
+ rounded-md
12
+ border
13
+ border-neutral-200
14
+ p-2
15
+ text-sm
16
+ text-neutral-700
17
+ motion-safe:transition-colors
18
+ dark:border-neutral-900
19
+ dark:text-neutral-300;
20
+
21
+ &:hover,
22
+ &:focus-visible {
23
+ @apply bg-neutral-100
24
+ dark:bg-neutral-900;
25
+ }
26
+ }
27
+
28
+ .dropdownContentWrapper {
29
+ @apply absolute
30
+ right-0
31
+ top-full
32
+ z-50
33
+ mt-1
34
+ max-h-80
35
+ w-52
36
+ overflow-hidden
37
+ rounded-sm
38
+ border
39
+ border-neutral-200
40
+ bg-white
41
+ shadow-lg
42
+ dark:border-neutral-900
43
+ dark:bg-neutral-950;
44
+ }
45
+
46
+ .dropdownContentInner {
47
+ @apply max-h-80
48
+ w-52
49
+ overflow-y-auto;
50
+ }
51
+
52
+ .dropdownItem {
53
+ @apply outline-hidden
54
+ block
55
+ px-2.5
56
+ py-1.5
57
+ text-sm
58
+ font-medium
59
+ text-neutral-800
60
+ no-underline
61
+ motion-safe:transition-colors
62
+ dark:text-white;
63
+
64
+ &:hover,
65
+ &:focus-visible {
66
+ @apply bg-green-600
67
+ text-white;
68
+ }
69
+ }
70
+
71
+ .dropdownLabel {
72
+ @apply block
73
+ text-sm
74
+ font-medium
75
+ leading-tight;
76
+ }
77
+
78
+ .dropdownVersions {
79
+ @apply block
80
+ text-xs
81
+ leading-tight
82
+ opacity-75;
83
+ }
@@ -0,0 +1,130 @@
1
+ import type { Meta as MetaObj, StoryObj } from '@storybook/react';
2
+
3
+ import ChangeHistory from '#ui/Common/ChangeHistory';
4
+
5
+ type Story = StoryObj<typeof ChangeHistory>;
6
+ type Meta = MetaObj<typeof ChangeHistory>;
7
+
8
+ const SAMPLE_CHANGES = [
9
+ {
10
+ versions: ['v15.4.0'],
11
+ label: 'No longer experimental',
12
+ url: 'https://github.com/nodejs/node/pull/12345',
13
+ },
14
+ {
15
+ versions: ['v15.0.0', 'v14.17.0'],
16
+ label: 'Added in v15.0.0, v14.17.0',
17
+ url: 'https://github.com/nodejs/node/pull/67890',
18
+ },
19
+ {
20
+ versions: ['v16.0.0'],
21
+ label: 'Deprecated in 16',
22
+ },
23
+ ];
24
+
25
+ const LARGE_SAMPLE_CHANGES = [
26
+ {
27
+ versions: ['v20.0.0'],
28
+ label: 'Breaking change in v20',
29
+ url: 'https://github.com/nodejs/node/pull/50001',
30
+ },
31
+ {
32
+ versions: ['v19.8.0'],
33
+ label: 'Performance improvement',
34
+ url: 'https://github.com/nodejs/node/pull/49999',
35
+ },
36
+ {
37
+ versions: ['v19.0.0'],
38
+ label: 'API redesign',
39
+ url: 'https://github.com/nodejs/node/pull/49000',
40
+ },
41
+ {
42
+ versions: ['v18.17.0', 'v18.16.1'],
43
+ label: 'Security fix backported',
44
+ url: 'https://github.com/nodejs/node/pull/48500',
45
+ },
46
+ {
47
+ versions: ['v18.0.0'],
48
+ label: 'Major version release',
49
+ url: 'https://github.com/nodejs/node/pull/47000',
50
+ },
51
+ {
52
+ versions: ['v17.9.0'],
53
+ label: 'Experimental feature added',
54
+ url: 'https://github.com/nodejs/node/pull/46500',
55
+ },
56
+ {
57
+ versions: ['v17.0.0'],
58
+ label: 'Node.js 17 release',
59
+ url: 'https://github.com/nodejs/node/pull/45000',
60
+ },
61
+ {
62
+ versions: ['v16.15.0', 'v16.14.2'],
63
+ label: 'Bug fix release',
64
+ url: 'https://github.com/nodejs/node/pull/44000',
65
+ },
66
+ {
67
+ versions: ['v16.0.0'],
68
+ label: 'Deprecated in v16',
69
+ url: 'https://github.com/nodejs/node/pull/43000',
70
+ },
71
+ {
72
+ versions: ['v15.14.0'],
73
+ label: 'Feature enhancement',
74
+ url: 'https://github.com/nodejs/node/pull/42000',
75
+ },
76
+ {
77
+ versions: ['v15.0.0', 'v14.17.0'],
78
+ label: 'Initial implementation',
79
+ url: 'https://github.com/nodejs/node/pull/41000',
80
+ },
81
+ {
82
+ versions: ['v14.18.0'],
83
+ label: 'Documentation update',
84
+ url: 'https://github.com/nodejs/node/pull/40000',
85
+ },
86
+ {
87
+ versions: ['v14.0.0'],
88
+ label: 'Added to stable API',
89
+ url: 'https://github.com/nodejs/node/pull/39000',
90
+ },
91
+ {
92
+ versions: ['v13.14.0'],
93
+ label: 'Experimental flag removed',
94
+ url: 'https://github.com/nodejs/node/pull/38000',
95
+ },
96
+ {
97
+ versions: ['v12.22.0', 'v12.21.0'],
98
+ label: 'Backported to LTS',
99
+ url: 'https://github.com/nodejs/node/pull/37000',
100
+ },
101
+ {
102
+ versions: ['v12.0.0'],
103
+ label: 'First experimental version',
104
+ url: 'https://github.com/nodejs/node/pull/36000',
105
+ },
106
+ ];
107
+
108
+ export const Default: Story = {
109
+ render: args => (
110
+ <div className="right-0 flex justify-end">
111
+ <ChangeHistory {...args} />
112
+ </div>
113
+ ),
114
+ args: {
115
+ changes: SAMPLE_CHANGES,
116
+ },
117
+ };
118
+
119
+ export const LargeHistory: Story = {
120
+ render: args => (
121
+ <div className="right-0 flex justify-end">
122
+ <ChangeHistory {...args} />
123
+ </div>
124
+ ),
125
+ args: {
126
+ changes: LARGE_SAMPLE_CHANGES,
127
+ },
128
+ };
129
+
130
+ export default { component: ChangeHistory } as Meta;
@@ -0,0 +1,67 @@
1
+ import { ChevronDownIcon, ClockIcon } from '@heroicons/react/24/outline';
2
+ import classNames from 'classnames';
3
+ import type { FC, ComponentProps } from 'react';
4
+
5
+ import type { LinkLike } from '#ui/types.js';
6
+
7
+ import styles from './index.module.css';
8
+
9
+ export type HistoryChange = {
10
+ versions: Array<string>;
11
+ label: string;
12
+ url?: string;
13
+ };
14
+
15
+ type ChangeHistoryProps = ComponentProps<'div'> & {
16
+ label: string;
17
+ changes: Array<HistoryChange>;
18
+ as?: LinkLike;
19
+ };
20
+
21
+ const ChangeHistory: FC<ChangeHistoryProps> = ({
22
+ label = 'History',
23
+ changes = [],
24
+ className,
25
+ as: As = 'a',
26
+ 'aria-label': ariaLabel = label,
27
+ ...props
28
+ }) => (
29
+ <div className={classNames('relative', 'inline-block', className)} {...props}>
30
+ <details className="group">
31
+ <summary className={styles.summary} role="button" aria-haspopup="menu">
32
+ <ClockIcon className="size-4" />
33
+ <span>{label}</span>
34
+ <ChevronDownIcon className="size-3 group-open:rotate-180 motion-safe:transition-transform" />
35
+ </summary>
36
+ <div
37
+ className={styles.dropdownContentWrapper}
38
+ role="menu"
39
+ aria-label={ariaLabel}
40
+ >
41
+ <div className={styles.dropdownContentInner}>
42
+ {changes.map((change, index) => {
43
+ const MenuItem = change.url ? As : 'div';
44
+
45
+ return (
46
+ <MenuItem
47
+ key={index}
48
+ className={styles.dropdownItem}
49
+ role="menuitem"
50
+ tabIndex={0}
51
+ aria-label={`${change.label}: ${change.versions.join(', ')}`}
52
+ href={change.url}
53
+ >
54
+ <div className={styles.dropdownLabel}>{change.label}</div>
55
+ <div className={styles.dropdownVersions}>
56
+ {change.versions.join(', ')}
57
+ </div>
58
+ </MenuItem>
59
+ );
60
+ })}
61
+ </div>
62
+ </div>
63
+ </details>
64
+ </div>
65
+ );
66
+
67
+ export default ChangeHistory;
File without changes
@@ -1,6 +1,6 @@
1
1
  import type { FC, SVGAttributes } from 'react';
2
2
 
3
- const ProgressionSidebarIcon: FC<SVGAttributes<SVGSVGElement>> = props => (
3
+ const ProgressionIcon: FC<SVGAttributes<SVGSVGElement>> = props => (
4
4
  <svg
5
5
  xmlns="http://www.w3.org/2000/svg"
6
6
  width="16"
@@ -13,4 +13,4 @@ const ProgressionSidebarIcon: FC<SVGAttributes<SVGSVGElement>> = props => (
13
13
  </svg>
14
14
  );
15
15
 
16
- export default ProgressionSidebarIcon;
16
+ export default ProgressionIcon;
@@ -5,22 +5,60 @@
5
5
  w-full
6
6
  flex-col
7
7
  gap-2;
8
- }
9
8
 
10
- .groupName {
11
- @apply px-2
12
- py-1
13
- text-xs
14
- font-semibold
15
- text-neutral-800
16
- dark:text-neutral-600;
17
- }
9
+ &:not(.progression) {
10
+ .groupName {
11
+ @apply px-2
12
+ py-1
13
+ text-xs
14
+ font-semibold
15
+ text-neutral-800
16
+ dark:text-neutral-600;
17
+ }
18
+ }
18
19
 
19
- .itemList {
20
- @apply m-0
21
- flex
22
- flex-col
23
- items-start
24
- gap-0.5
25
- p-0;
20
+ &.progression {
21
+ @apply flex
22
+ flex-col
23
+ gap-4
24
+ text-sm
25
+ font-medium
26
+ text-neutral-800
27
+ dark:text-neutral-200;
28
+
29
+ .itemList {
30
+ @apply relative
31
+ -left-1
32
+ flex
33
+ flex-col
34
+ after:absolute
35
+ after:left-[0.45rem]
36
+ after:top-0
37
+ after:z-10
38
+ after:h-full
39
+ after:w-px
40
+ after:bg-neutral-200
41
+ after:content-['']
42
+ dark:after:bg-neutral-800;
43
+
44
+ a {
45
+ @apply first:before:absolute
46
+ first:before:bottom-[calc(50%+0.25rem)]
47
+ first:before:left-0
48
+ first:before:h-20
49
+ first:before:w-4
50
+ first:before:bg-white
51
+ first:before:content-['']
52
+ last:after:absolute
53
+ last:after:left-0
54
+ last:after:top-[calc(50%+0.25rem)]
55
+ last:after:h-20
56
+ last:after:w-4
57
+ last:after:bg-white
58
+ last:after:content-['']
59
+ first:dark:before:bg-neutral-950
60
+ last:dark:after:bg-neutral-950;
61
+ }
62
+ }
63
+ }
26
64
  }
@@ -1,3 +1,4 @@
1
+ import classNames from 'classnames';
1
2
  import type { ComponentProps, FC } from 'react';
2
3
 
3
4
  import SidebarItem from '#ui/Containers/Sidebar/SidebarItem';
@@ -10,18 +11,36 @@ type SidebarGroupProps = {
10
11
  items: Array<Omit<ComponentProps<typeof SidebarItem>, 'as' | 'pathname'>>;
11
12
  as?: LinkLike;
12
13
  pathname?: string;
14
+ className: string;
15
+ showProgressionIcons?: boolean;
13
16
  };
14
17
 
15
18
  const SidebarGroup: FC<SidebarGroupProps> = ({
16
19
  groupName,
17
20
  items,
21
+ showProgressionIcons,
22
+ className,
18
23
  ...props
19
24
  }) => (
20
- <section className={styles.group}>
25
+ <section
26
+ className={classNames(
27
+ {
28
+ [styles.group]: true,
29
+ [styles.progression]: showProgressionIcons,
30
+ },
31
+ className
32
+ )}
33
+ >
21
34
  <label className={styles.groupName}>{groupName}</label>
22
35
  <ul className={styles.itemList}>
23
36
  {items.map(({ label, link }) => (
24
- <SidebarItem key={link} label={label} link={link} {...props} />
37
+ <SidebarItem
38
+ key={link}
39
+ label={label}
40
+ link={link}
41
+ showProgressionIcons={showProgressionIcons}
42
+ {...props}
43
+ />
25
44
  ))}
26
45
  </ul>
27
46
  </section>
@@ -1,35 +1,56 @@
1
- @reference "../../../styles/index.css";
1
+ @reference '../../../styles/index.css';
2
2
 
3
- .sideBarItem {
4
- @apply flex
3
+ .item {
4
+ @apply font-regular
5
+ relative
6
+ z-20
7
+ flex
5
8
  w-full
6
- list-none
9
+ items-center
10
+ overflow-hidden
11
+ text-sm
7
12
  text-neutral-800
8
13
  dark:text-neutral-200;
9
14
 
10
- a {
11
- @apply inline-flex
12
- items-center
13
- gap-2
14
- p-2;
15
- }
16
-
17
15
  .label {
18
16
  @apply font-regular
19
- w-full
17
+ p-2
20
18
  text-sm;
21
19
  }
22
20
 
21
+ .progressionIcon {
22
+ @apply shrink-0
23
+ fill-neutral-200
24
+ stroke-white
25
+ stroke-[4]
26
+ dark:fill-neutral-800
27
+ dark:stroke-neutral-950;
28
+ }
29
+
23
30
  .icon {
24
31
  @apply size-3
25
32
  text-neutral-500
26
33
  dark:text-neutral-200;
27
34
  }
28
- }
29
35
 
30
- .active {
31
- @apply rounded-sm
32
- bg-green-600
33
- text-white
34
- dark:text-white;
36
+ &.progression {
37
+ .label {
38
+ @apply p-1;
39
+ }
40
+ }
41
+
42
+ &.active {
43
+ @apply text-neutral-900
44
+ dark:text-white;
45
+
46
+ .progressionIcon {
47
+ @apply fill-green-500;
48
+ }
49
+
50
+ &:not(.progression) .label {
51
+ @apply rounded-sm
52
+ bg-green-600
53
+ text-white;
54
+ }
55
+ }
35
56
  }
@@ -1,26 +1,43 @@
1
1
  import { ArrowUpRightIcon } from '@heroicons/react/24/solid';
2
+ import classNames from 'classnames';
2
3
  import type { FC } from 'react';
3
4
 
4
- import ActiveLink from '#ui/Common/BaseActiveLink';
5
+ import BaseActiveLink from '#ui/Common/BaseActiveLink';
5
6
  import type { FormattedMessage, LinkLike } from '#ui/types';
6
7
 
7
8
  import styles from './index.module.css';
9
+ import ProgressionIcon from '../ProgressionIcon';
8
10
 
9
11
  type SidebarItemProps = {
10
12
  label: FormattedMessage;
11
13
  link: string;
12
14
  as?: LinkLike;
13
15
  pathname?: string;
16
+ showProgressionIcons?: boolean;
14
17
  };
15
18
 
16
- const SidebarItem: FC<SidebarItemProps> = ({ label, link, ...props }) => (
17
- <li className={styles.sideBarItem}>
18
- <ActiveLink href={link} activeClassName={styles.active} {...props}>
19
- <span className={styles.label}>{label}</span>
19
+ const SidebarItem: FC<SidebarItemProps> = ({
20
+ label,
21
+ link,
22
+ showProgressionIcons = false,
23
+ ...props
24
+ }) => (
25
+ <BaseActiveLink
26
+ className={classNames({
27
+ [styles.item]: true,
28
+ [styles.progression]: showProgressionIcons,
29
+ })}
30
+ href={link}
31
+ activeClassName={styles.active}
32
+ {...props}
33
+ >
34
+ {showProgressionIcons && (
35
+ <ProgressionIcon className={styles.progressionIcon} />
36
+ )}
37
+ <span className={styles.label}>{label}</span>
20
38
 
21
- {link.startsWith('http') && <ArrowUpRightIcon className={styles.icon} />}
22
- </ActiveLink>
23
- </li>
39
+ {/^https?:/.test(link) && <ArrowUpRightIcon className={styles.icon} />}
40
+ </BaseActiveLink>
24
41
  );
25
42
 
26
43
  export default SidebarItem;
@@ -4,26 +4,25 @@
4
4
  @apply flex
5
5
  w-full
6
6
  flex-col
7
- items-start
8
7
  gap-8
9
8
  overflow-auto
10
- overflow-x-hidden
11
- border-r-neutral-200
9
+ border-r-0
10
+ border-neutral-200
12
11
  bg-white
13
12
  px-4
14
13
  py-6
15
14
  sm:border-r
16
15
  md:max-w-xs
17
16
  lg:px-6
18
- dark:border-r-neutral-900
17
+ dark:border-neutral-900
19
18
  dark:bg-neutral-950;
20
19
 
21
- > section {
20
+ .navigation {
22
21
  @apply hidden
23
22
  sm:flex;
24
23
  }
25
24
 
26
- > span {
25
+ .mobileSelect {
27
26
  @apply flex
28
27
  w-full
29
28
  sm:hidden;