@atom-learning/components 2.1.0 → 2.2.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.
- package/CHANGELOG.md +0 -7
- package/dist/components/index.d.ts +1 -0
- package/dist/components/navigation/NavigationMenu.d.ts +15 -0
- package/dist/components/navigation/NavigationMenu.js +1 -0
- package/dist/components/navigation/NavigationMenuContext.d.ts +7 -0
- package/dist/components/navigation/NavigationMenuContext.js +1 -0
- package/dist/components/navigation/NavigationMenuDropdown.d.ts +7 -0
- package/dist/components/navigation/NavigationMenuDropdown.js +1 -0
- package/dist/components/navigation/NavigationMenuItem.d.ts +287 -0
- package/dist/components/navigation/NavigationMenuItem.js +1 -0
- package/dist/components/navigation/index.d.ts +1 -0
- package/dist/docgen.json +1 -1
- package/dist/docs/NavigationMenu.mdx +113 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
# [2.1.0](https://github.com/Atom-Learning/components/compare/v2.0.0...v2.1.0) (2022-09-09)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* inline message ([e973432](https://github.com/Atom-Learning/components/commit/e97343211f5ed65a53d3b82bba5157b3854161a5))
|
|
7
|
-
|
|
8
1
|
# [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
|
|
9
2
|
|
|
10
3
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CSS } from '../../stitches';
|
|
3
|
+
import { NavigationMenuDropdown } from './NavigationMenuDropdown';
|
|
4
|
+
import { NavigationMenuDropdownContent, NavigationMenuDropdownItem, NavigationMenuLink } from './NavigationMenuItem';
|
|
5
|
+
declare type NavigationMenuSubComponents = {
|
|
6
|
+
Link: typeof NavigationMenuLink;
|
|
7
|
+
Dropdown: typeof NavigationMenuDropdown;
|
|
8
|
+
DropdownContent: typeof NavigationMenuDropdownContent;
|
|
9
|
+
DropdownItem: typeof NavigationMenuDropdownItem;
|
|
10
|
+
};
|
|
11
|
+
declare type NavigationMenuProps = {
|
|
12
|
+
css?: CSS;
|
|
13
|
+
};
|
|
14
|
+
export declare const NavigationMenu: React.FC<NavigationMenuProps> & NavigationMenuSubComponents;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as l from"@radix-ui/react-navigation-menu";import t from"react";import{DIALOG_Z_INDEX as M}from"../../constants/dialog.js";import{keyframes as h,styled as n}from"../../stitches.js";import{fadeOut as w}from"../../utilities/style/keyframe-animations.js";import{NavigationMenuContext as x}from"./NavigationMenuContext.js";import{NavigationMenuDropdown as D}from"./NavigationMenuDropdown.js";import{NavigationMenuLink as E,NavigationMenuDropdownContent as C,NavigationMenuDropdownItem as $}from"./NavigationMenuItem.js";const I=h({"0%, 50%":{opacity:0},"100%":{opacity:1}}),L=n(l.Root,{display:"flex",justifyContent:"center",position:"relative"}),k=n(l.List,{all:"unset",display:"flex",justifyContent:"center",alignItems:"center",gap:"$1",listStyle:"none"}),S=n(l.Viewport,{zIndex:M}),_=n("div",{position:"absolute",left:0,top:"100%",width:"100%",display:"flex",justifyContent:"center"}),o=({children:f,css:m})=>{const[p,u]=t.useState(),[a,c]=t.useState(),[i,d]=t.useState(0),r=t.useRef(null),s=200;t.useLayoutEffect(()=>{r.current&&d(r.current.offsetWidth)},[]),t.useEffect(()=>{let e;return a===""&&(e=setTimeout(()=>u(null),s)),()=>{e!==null&&clearTimeout(e)}},[a]);const y=(e,v)=>{if(e&&i&&a===v){const g=i/2,N=i-e.offsetLeft-e.offsetWidth+e.offsetWidth/2;u(Math.round(g-N))}return e};return t.createElement(x.Provider,{value:{onNodeUpdate:y}},t.createElement(L,{onValueChange:c,css:m},t.createElement(k,{ref:r},f),t.createElement(_,null,t.createElement(S,{css:{transform:`translateX(${p||0}px)`,'&[data-state="open"]':{animation:`${I} ${s}ms ease`},'&[data-state="closed"]':{animation:`${w} ${s}ms ease-out`}}}))))};o.Link=E,o.Dropdown=D,o.DropdownContent=C,o.DropdownItem=$,o.displayName="NavigationMenu";export{o as NavigationMenu};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface NavigationMenuContextValue {
|
|
3
|
+
onNodeUpdate: (trigger: HTMLButtonElement, itemValue: string) => HTMLButtonElement;
|
|
4
|
+
}
|
|
5
|
+
export declare const NavigationMenuContext: React.Context<NavigationMenuContextValue | undefined>;
|
|
6
|
+
export declare const useNavigationMenuContext: () => NavigationMenuContextValue;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"react";const o=e.createContext(void 0),n=()=>{const t=e.useContext(o);if(t===void 0)throw new Error("useNavigationMenuContext must be used within a NavigationMenuContextProvider");return t};export{o as NavigationMenuContext,n as useNavigationMenuContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"@radix-ui/react-navigation-menu";import t from"react";import{styled as p}from"../../stitches.js";import{useNavigationMenuContext as m}from"./NavigationMenuContext.js";import{NavigationMenuDropdownTrigger as d}from"./NavigationMenuItem.js";const l=p(r.Content,{p:"$3",bg:"white",mt:"4px",boxShadow:"0px 3px 6px rgba(51, 51, 51, 0.15), 0px 3px 6px rgba(51, 51, 51, 0.2)",borderRadius:"$1"}),u=({children:o,title:e,...n})=>{const{onNodeUpdate:a}=m();return t.createElement(r.Item,{value:e},t.createElement(d,{...n,ref:i=>a(i,e)},e),t.createElement(l,null,o))};export{u as NavigationMenuDropdown};
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CSS } from '../../stitches';
|
|
3
|
+
export declare const NavigationMenuDropdownTrigger: React.ForwardRefExoticComponent<{
|
|
4
|
+
active?: boolean | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
export declare const NavigationMenuDropdownContent: import("@stitches/react/types/styled-component").StyledComponent<"ul", {}, {
|
|
9
|
+
sm: string;
|
|
10
|
+
md: string;
|
|
11
|
+
lg: string;
|
|
12
|
+
xl: string;
|
|
13
|
+
reducedMotion: string;
|
|
14
|
+
allowMotion: string;
|
|
15
|
+
hover: string;
|
|
16
|
+
}, import("@stitches/react/types/css-util").CSS<{
|
|
17
|
+
sm: string;
|
|
18
|
+
md: string;
|
|
19
|
+
lg: string;
|
|
20
|
+
xl: string;
|
|
21
|
+
reducedMotion: string;
|
|
22
|
+
allowMotion: string;
|
|
23
|
+
hover: string;
|
|
24
|
+
}, {
|
|
25
|
+
colors: {
|
|
26
|
+
textForeground: any;
|
|
27
|
+
textSubtle: any;
|
|
28
|
+
textPlaceholder: any;
|
|
29
|
+
background: any;
|
|
30
|
+
backgroundAccent: any;
|
|
31
|
+
tonal50: any;
|
|
32
|
+
tonal100: any;
|
|
33
|
+
tonal200: any;
|
|
34
|
+
tonal300: any;
|
|
35
|
+
tonal400: any;
|
|
36
|
+
tonal500: any;
|
|
37
|
+
tonal600: any;
|
|
38
|
+
alpha100: any;
|
|
39
|
+
alpha150: any;
|
|
40
|
+
alpha200: any;
|
|
41
|
+
alpha250: any;
|
|
42
|
+
alpha600: any;
|
|
43
|
+
primaryLight: any;
|
|
44
|
+
primary: any;
|
|
45
|
+
primaryMid: any;
|
|
46
|
+
primaryDark: any;
|
|
47
|
+
secondary: any;
|
|
48
|
+
brandRed: any;
|
|
49
|
+
brandRedAccent: any;
|
|
50
|
+
brandGreen: any;
|
|
51
|
+
brandGreenAccent: any;
|
|
52
|
+
brandPurple: any;
|
|
53
|
+
brandPurpleAccent: any;
|
|
54
|
+
brandYellow: any;
|
|
55
|
+
brandYellowAccent: any;
|
|
56
|
+
successLight: any;
|
|
57
|
+
success: any;
|
|
58
|
+
successMid: any;
|
|
59
|
+
successDark: any;
|
|
60
|
+
dangerLight: any;
|
|
61
|
+
danger: any;
|
|
62
|
+
dangerMid: any;
|
|
63
|
+
dangerDark: any;
|
|
64
|
+
warningLight: any;
|
|
65
|
+
warning: any;
|
|
66
|
+
warningMid: any;
|
|
67
|
+
warningDark: any;
|
|
68
|
+
warningText: any;
|
|
69
|
+
subjectEnglish: any;
|
|
70
|
+
subjectMaths: any;
|
|
71
|
+
subjectScience: any;
|
|
72
|
+
subjectVerbalReasoning: any;
|
|
73
|
+
subjectNonVerbalReasoning: any;
|
|
74
|
+
subjectCreativeWriting: any;
|
|
75
|
+
subjectExamSkills: any;
|
|
76
|
+
};
|
|
77
|
+
space: {
|
|
78
|
+
"0": any;
|
|
79
|
+
"1": any;
|
|
80
|
+
"2": any;
|
|
81
|
+
"3": any;
|
|
82
|
+
"4": any;
|
|
83
|
+
"5": any;
|
|
84
|
+
"6": any;
|
|
85
|
+
"7": any;
|
|
86
|
+
"8": any;
|
|
87
|
+
"9": any;
|
|
88
|
+
};
|
|
89
|
+
fontSizes: {
|
|
90
|
+
xs: any;
|
|
91
|
+
sm: any;
|
|
92
|
+
md: any;
|
|
93
|
+
lg: any;
|
|
94
|
+
xl: any;
|
|
95
|
+
"2xl": any;
|
|
96
|
+
"3xl": any;
|
|
97
|
+
"4xl": any;
|
|
98
|
+
};
|
|
99
|
+
fonts: {
|
|
100
|
+
sans: any;
|
|
101
|
+
mono: any;
|
|
102
|
+
display: any;
|
|
103
|
+
body: any;
|
|
104
|
+
};
|
|
105
|
+
sizes: {
|
|
106
|
+
"0": any;
|
|
107
|
+
"1": any;
|
|
108
|
+
"2": any;
|
|
109
|
+
"3": any;
|
|
110
|
+
"4": any;
|
|
111
|
+
"5": any;
|
|
112
|
+
"6": any;
|
|
113
|
+
"7": any;
|
|
114
|
+
"8": any;
|
|
115
|
+
};
|
|
116
|
+
radii: {
|
|
117
|
+
"0": any;
|
|
118
|
+
"1": any;
|
|
119
|
+
"2": any;
|
|
120
|
+
"3": any;
|
|
121
|
+
round: any;
|
|
122
|
+
};
|
|
123
|
+
shadows: {
|
|
124
|
+
"0": any;
|
|
125
|
+
"1": any;
|
|
126
|
+
"2": any;
|
|
127
|
+
"3": any;
|
|
128
|
+
};
|
|
129
|
+
}, import("@stitches/react/types/config").DefaultThemeMap, {
|
|
130
|
+
bg: (value: {
|
|
131
|
+
readonly [$$PropertyValue]: "background";
|
|
132
|
+
}) => {
|
|
133
|
+
background: {
|
|
134
|
+
readonly [$$PropertyValue]: "background";
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
inset: (value: string | number | {
|
|
138
|
+
readonly [$$ScaleValue]: "space";
|
|
139
|
+
}) => {
|
|
140
|
+
top: string | number | {
|
|
141
|
+
readonly [$$ScaleValue]: "space";
|
|
142
|
+
};
|
|
143
|
+
right: string | number | {
|
|
144
|
+
readonly [$$ScaleValue]: "space";
|
|
145
|
+
};
|
|
146
|
+
bottom: string | number | {
|
|
147
|
+
readonly [$$ScaleValue]: "space";
|
|
148
|
+
};
|
|
149
|
+
left: string | number | {
|
|
150
|
+
readonly [$$ScaleValue]: "space";
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
size: (value: string | number | {
|
|
154
|
+
readonly [$$ScaleValue]: "size";
|
|
155
|
+
}) => {
|
|
156
|
+
height: string | number | {
|
|
157
|
+
readonly [$$ScaleValue]: "size";
|
|
158
|
+
};
|
|
159
|
+
width: string | number | {
|
|
160
|
+
readonly [$$ScaleValue]: "size";
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
p: (value: string | number | {
|
|
164
|
+
readonly [$$ScaleValue]: "space";
|
|
165
|
+
}) => {
|
|
166
|
+
padding: string | number | {
|
|
167
|
+
readonly [$$ScaleValue]: "space";
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
pt: (value: string | number | {
|
|
171
|
+
readonly [$$ScaleValue]: "space";
|
|
172
|
+
}) => {
|
|
173
|
+
paddingTop: string | number | {
|
|
174
|
+
readonly [$$ScaleValue]: "space";
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
pr: (value: string | number | {
|
|
178
|
+
readonly [$$ScaleValue]: "space";
|
|
179
|
+
}) => {
|
|
180
|
+
paddingRight: string | number | {
|
|
181
|
+
readonly [$$ScaleValue]: "space";
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
pb: (value: string | number | {
|
|
185
|
+
readonly [$$ScaleValue]: "space";
|
|
186
|
+
}) => {
|
|
187
|
+
paddingBottom: string | number | {
|
|
188
|
+
readonly [$$ScaleValue]: "space";
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
pl: (value: string | number | {
|
|
192
|
+
readonly [$$ScaleValue]: "space";
|
|
193
|
+
}) => {
|
|
194
|
+
paddingLeft: string | number | {
|
|
195
|
+
readonly [$$ScaleValue]: "space";
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
px: (value: string | number | {
|
|
199
|
+
readonly [$$ScaleValue]: "space";
|
|
200
|
+
}) => {
|
|
201
|
+
paddingLeft: string | number | {
|
|
202
|
+
readonly [$$ScaleValue]: "space";
|
|
203
|
+
};
|
|
204
|
+
paddingRight: string | number | {
|
|
205
|
+
readonly [$$ScaleValue]: "space";
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
py: (value: string | number | {
|
|
209
|
+
readonly [$$ScaleValue]: "space";
|
|
210
|
+
}) => {
|
|
211
|
+
paddingTop: string | number | {
|
|
212
|
+
readonly [$$ScaleValue]: "space";
|
|
213
|
+
};
|
|
214
|
+
paddingBottom: string | number | {
|
|
215
|
+
readonly [$$ScaleValue]: "space";
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
m: (value: string | number | {
|
|
219
|
+
readonly [$$ScaleValue]: "space";
|
|
220
|
+
}) => {
|
|
221
|
+
margin: string | number | {
|
|
222
|
+
readonly [$$ScaleValue]: "space";
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
mt: (value: string | number | {
|
|
226
|
+
readonly [$$ScaleValue]: "space";
|
|
227
|
+
}) => {
|
|
228
|
+
marginTop: string | number | {
|
|
229
|
+
readonly [$$ScaleValue]: "space";
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
mr: (value: string | number | {
|
|
233
|
+
readonly [$$ScaleValue]: "space";
|
|
234
|
+
}) => {
|
|
235
|
+
marginRight: string | number | {
|
|
236
|
+
readonly [$$ScaleValue]: "space";
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
mb: (value: string | number | {
|
|
240
|
+
readonly [$$ScaleValue]: "space";
|
|
241
|
+
}) => {
|
|
242
|
+
marginBottom: string | number | {
|
|
243
|
+
readonly [$$ScaleValue]: "space";
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
ml: (value: string | number | {
|
|
247
|
+
readonly [$$ScaleValue]: "space";
|
|
248
|
+
}) => {
|
|
249
|
+
marginLeft: string | number | {
|
|
250
|
+
readonly [$$ScaleValue]: "space";
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
mx: (value: string | number | {
|
|
254
|
+
readonly [$$ScaleValue]: "space";
|
|
255
|
+
}) => {
|
|
256
|
+
marginLeft: string | number | {
|
|
257
|
+
readonly [$$ScaleValue]: "space";
|
|
258
|
+
};
|
|
259
|
+
marginRight: string | number | {
|
|
260
|
+
readonly [$$ScaleValue]: "space";
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
my: (value: string | number | {
|
|
264
|
+
readonly [$$ScaleValue]: "space";
|
|
265
|
+
}) => {
|
|
266
|
+
marginTop: string | number | {
|
|
267
|
+
readonly [$$ScaleValue]: "space";
|
|
268
|
+
};
|
|
269
|
+
marginBottom: string | number | {
|
|
270
|
+
readonly [$$ScaleValue]: "space";
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
}>>;
|
|
274
|
+
declare type NavigationMenuLinkProps = {
|
|
275
|
+
href: string;
|
|
276
|
+
active?: boolean;
|
|
277
|
+
disabled?: boolean;
|
|
278
|
+
variant?: 'link' | 'dropdownItem';
|
|
279
|
+
css?: CSS;
|
|
280
|
+
};
|
|
281
|
+
export declare const NavigationMenuLink: React.ForwardRefExoticComponent<NavigationMenuLinkProps & {
|
|
282
|
+
children?: React.ReactNode;
|
|
283
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
284
|
+
export declare const NavigationMenuDropdownItem: React.ForwardRefExoticComponent<NavigationMenuLinkProps & {
|
|
285
|
+
children?: React.ReactNode;
|
|
286
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
287
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ChevronDown as u}from"@atom-learning/icons";import*as d from"@radix-ui/react-navigation-menu";import e from"react";import{theme as b,styled as r}from"../../stitches.js";import{Icon as g}from"../icon/Icon.js";const s={fontWeight:"bold",color:"$tonal500","&::after":{backgroundColor:"$tonal500",borderRadius:"$1",bottom:0,content:"",display:"block",height:"2px",left:"50%",position:"absolute",transform:"translate(-50%,0)",width:"$2"}},c={background:"none",color:"$tonal400",opacity:"30%",cursor:"default"},i={all:"unset",position:"relative",color:"$tonal400",outline:"none",cursor:"pointer",fontFamily:"$body",userSelect:"none",padding:"$3",borderRadius:"$1","&:hover":{background:"$tonal50",color:"$tonal600"},"&:active":{background:"$tonal100",color:"$tonal600"},"&:focus-visible":{boxShadow:`0 0 0 2px ${b.colors.primary}`},"&:disabled":{...c}},v=r(d.Trigger,i,{display:"flex",alignItems:"center",borderRadius:"$1",justifyContent:"space-between",gap:"$1",'&[data-state="open"]':{background:"$tonal100"},variants:{active:{true:{...s}}}}),$=r(d.Link,i,{display:"block",textDecoration:"none",lineHeight:1,variants:{elementType:{dropdownItem:{"&[data-active]":{background:"$primaryLight",color:"$primary"}},link:{"&[data-active]":{...s}}}}}),h=e.forwardRef(({children:o,active:t,...a},n)=>e.createElement(v,{active:t,...a,ref:n},o,e.createElement(g,{is:u,css:{"[data-state=open] &":{transform:"rotate(-180deg)"},"@media (prefers-reduced-motion: no-preference)":{transition:"transform .2s ease"}},size:"sm"}))),y=r("ul",{all:"unset"}),k=r("li",{all:"unset"}),w=r("button",{...i,...c}),m=e.forwardRef(({children:o,href:t,disabled:a,css:n,variant:p="link",...l},f)=>a?e.createElement(w,{disabled:!0,...l},o):e.createElement(k,null,e.createElement($,{href:t,ref:f,elementType:p,css:n,...l},o))),x=e.forwardRef((o,t)=>e.createElement(m,{ref:t,variant:"dropdownItem",...o}));export{y as NavigationMenuDropdownContent,x as NavigationMenuDropdownItem,h as NavigationMenuDropdownTrigger,m as NavigationMenuLink};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NavigationMenu } from './NavigationMenu';
|