@nautui/core 0.1.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.
Files changed (54) hide show
  1. package/README.md +148 -0
  2. package/package.json +35 -0
  3. package/src/components/Accordion.astro +24 -0
  4. package/src/components/AccordionItem.astro +172 -0
  5. package/src/components/Background.astro +75 -0
  6. package/src/components/Badge.astro +140 -0
  7. package/src/components/Bento.astro +37 -0
  8. package/src/components/BentoItem.astro +26 -0
  9. package/src/components/Box.astro +189 -0
  10. package/src/components/Breadcrumb.astro +62 -0
  11. package/src/components/Button.astro +273 -0
  12. package/src/components/Card.astro +228 -0
  13. package/src/components/Container.astro +76 -0
  14. package/src/components/Divider.astro +85 -0
  15. package/src/components/Drawer.astro +139 -0
  16. package/src/components/Flex.astro +150 -0
  17. package/src/components/Flow.astro +119 -0
  18. package/src/components/Grid.astro +335 -0
  19. package/src/components/GridItem.astro +225 -0
  20. package/src/components/Group.astro +106 -0
  21. package/src/components/Image.astro +191 -0
  22. package/src/components/Link.astro +118 -0
  23. package/src/components/List.astro +57 -0
  24. package/src/components/ListItem.astro +31 -0
  25. package/src/components/Mark.astro +161 -0
  26. package/src/components/Marquee.astro +193 -0
  27. package/src/components/Masonry.astro +75 -0
  28. package/src/components/MasonryItem.astro +28 -0
  29. package/src/components/Menu.astro +71 -0
  30. package/src/components/MenuItem.astro +93 -0
  31. package/src/components/NavBar.astro +211 -0
  32. package/src/components/Section.astro +108 -0
  33. package/src/components/Space.astro +400 -0
  34. package/src/components/Stack.astro +237 -0
  35. package/src/components/Text.astro +270 -0
  36. package/src/components/Theme.astro +37 -0
  37. package/src/components/ThemeToggle.astro +141 -0
  38. package/src/components/Title.astro +141 -0
  39. package/src/index.d.ts +80 -0
  40. package/src/index.ts +77 -0
  41. package/src/lib/border.ts +92 -0
  42. package/src/lib/pattern.ts +37 -0
  43. package/src/lib/spacing.ts +48 -0
  44. package/src/styles/border.css +180 -0
  45. package/src/styles/colors.css +99 -0
  46. package/src/styles/global.css +57 -0
  47. package/src/styles/radius.css +22 -0
  48. package/src/styles/shadow.css +11 -0
  49. package/src/styles/spacing/display.css +198 -0
  50. package/src/styles/spacing/gap.css +19 -0
  51. package/src/styles/spacing/margin.css +157 -0
  52. package/src/styles/spacing/padding.css +154 -0
  53. package/src/styles/spacing/spacing.css +2 -0
  54. package/src/types.ts +10 -0
@@ -0,0 +1,189 @@
1
+ ---
2
+ import "../styles/spacing/padding.css";
3
+ import "../styles/spacing/margin.css";
4
+ import "../styles/border.css";
5
+ import "../styles/radius.css";
6
+ import { type Border, createBorder } from "../lib/border";
7
+ import {
8
+ extractSpacingProps,
9
+ getSpacingClasses,
10
+ SpacingProps,
11
+ } from "../lib/spacing";
12
+ import type { Base, Radius } from "../types";
13
+
14
+ type CornerStyle = "diamond" | "square" | "circle" | "plus" | "x";
15
+
16
+ export interface Corner {
17
+ bottomLeft?: CornerStyle;
18
+ bottomRight?: CornerStyle;
19
+ topLeft?: CornerStyle;
20
+ topRight?: CornerStyle;
21
+ }
22
+
23
+ export interface BoxProps extends Base, SpacingProps {
24
+ border?: Border;
25
+ centered?: boolean;
26
+ corner?: Corner;
27
+ radius?: Radius;
28
+ }
29
+
30
+ const { padding, margin, nonSpacing } = extractSpacingProps(
31
+ Astro.props as BoxProps
32
+ );
33
+
34
+ const {
35
+ border,
36
+ radius,
37
+ corner,
38
+ centered = false,
39
+ class: className,
40
+ ...rest
41
+ } = nonSpacing;
42
+
43
+ const borderConfig =
44
+ typeof border === "string" ? { width: border } : border || {};
45
+ const { borderClasses, borderColors } = createBorder(borderConfig);
46
+
47
+ const p = Object.keys(padding).length === 0 ? "md" : padding.p;
48
+ const marginClasses = getSpacingClasses({ ...margin });
49
+ const paddingClasses = getSpacingClasses({ ...padding, p });
50
+ const classlist = [
51
+ "naut-box",
52
+ radius && `radius-${radius}`,
53
+ centered && "centered",
54
+ className,
55
+ ...borderClasses,
56
+ ...marginClasses,
57
+ ];
58
+ ---
59
+
60
+ <div class:list={classlist} {...rest}>
61
+ {corner?.topLeft && <span class:list={["corner", "top-left", corner.topLeft]} />}
62
+ {corner?.topRight && <span class:list={["corner", "top-right", corner.topRight]} />}
63
+ {corner?.bottomRight && <span class:list={["corner", "bottom-right", corner.bottomRight]} />}
64
+ {corner?.bottomLeft && <span class:list={["corner", "bottom-left", corner.bottomLeft]} />}
65
+ <slot name="background" />
66
+ <slot name="before" />
67
+ <div class:list={["naut-box--wrapper", ...paddingClasses]}><slot /></div>
68
+ <slot name="after" />
69
+ </div>
70
+
71
+ <style define:vars={{ ...borderColors }}>
72
+ .naut-box {
73
+ position: relative;
74
+ display: flow-root; /* Prevents margin collapsing */
75
+
76
+ &.centered {
77
+ display: flex;
78
+ align-items: center;
79
+ justify-content: center;
80
+ height: 100%;
81
+ }
82
+
83
+ .naut-box--wrapper {
84
+ position: relative;
85
+ overflow: hidden;
86
+ }
87
+
88
+ .corner {
89
+ position: absolute;
90
+ z-index: 1;
91
+ width: 9px;
92
+ height: 9px;
93
+
94
+ &.square,
95
+ &.circle,
96
+ &.diamond {
97
+ background-color: var(--naut-color-base);
98
+ border: 1px solid var(--naut-color-border);
99
+
100
+ &.top-left {
101
+ top: -0.38rem;
102
+ left: -0.35rem;
103
+ }
104
+
105
+ &.top-right {
106
+ top: -0.38rem;
107
+ right: -0.4rem;
108
+ }
109
+
110
+ &.bottom-left {
111
+ bottom: -0.35rem;
112
+ left: -0.36rem;
113
+ }
114
+
115
+ &.bottom-right {
116
+ right: -0.4rem;
117
+ bottom: -0.35rem;
118
+ }
119
+ }
120
+
121
+ &.circle {
122
+ border-radius: 50%;
123
+ }
124
+
125
+ &.diamond {
126
+ transform: rotate(45deg);
127
+ }
128
+
129
+ &.plus,
130
+ &.x {
131
+ &.top-left {
132
+ top: -0.33rem;
133
+ left: -0.31rem;
134
+ }
135
+
136
+ &.top-right {
137
+ top: -0.33rem;
138
+ right: -0.32rem;
139
+ }
140
+
141
+ &.bottom-left {
142
+ bottom: -0.32rem;
143
+ left: -0.31rem;
144
+ }
145
+
146
+ &.bottom-right {
147
+ right: -0.32rem;
148
+ bottom: -0.32rem;
149
+ }
150
+
151
+ &::before,
152
+ &::after {
153
+ position: absolute;
154
+ top: 50%;
155
+ left: 50%;
156
+ content: "";
157
+ background-color: var(--naut-color-border-strong);
158
+ }
159
+ }
160
+
161
+ &.plus {
162
+ &::before {
163
+ width: 1px;
164
+ height: 100%;
165
+ transform: translate(-50%, -50%);
166
+ }
167
+
168
+ &::after {
169
+ width: 100%;
170
+ height: 1px;
171
+ transform: translate(-50%, -50%);
172
+ }
173
+ }
174
+
175
+ &.x {
176
+ &::before,
177
+ &::after {
178
+ width: 100%;
179
+ height: 1px;
180
+ transform: translate(-50%, -50%) rotate(45deg);
181
+ }
182
+
183
+ &::after {
184
+ transform: translate(-50%, -50%) rotate(-45deg);
185
+ }
186
+ }
187
+ }
188
+ }
189
+ </style>
@@ -0,0 +1,62 @@
1
+ ---
2
+ import type { Base } from "../types";
3
+
4
+ interface BreadcrumbItem {
5
+ href?: string;
6
+ label: string;
7
+ }
8
+
9
+ export interface BreadcrumbProps extends Base {
10
+ className?: string;
11
+ items: BreadcrumbItem[];
12
+ }
13
+
14
+ const { items, class: className } = Astro.props as BreadcrumbProps;
15
+ ---
16
+
17
+ <nav class:list={["naut-breadcrumb", className]}>
18
+ <ol>
19
+ {items.map((item) => (
20
+ <li>
21
+ {item.href && <a href={item.href} title={item.label}>{item.label}</a>}
22
+ {!item.href && <span>{item.label}</span>}
23
+ </li>
24
+ ))}
25
+ </ol>
26
+ </nav>
27
+
28
+ <style>
29
+ .naut-breadcrumb {
30
+ ol {
31
+ display: flex;
32
+ flex-wrap: wrap;
33
+ gap: 1rem;
34
+ align-items: center;
35
+ padding: 0;
36
+ margin: 0;
37
+ list-style: none;
38
+
39
+ li {
40
+ display: flex;
41
+ flex-wrap: nowrap;
42
+ gap: 0.5rem;
43
+ align-items: center;
44
+
45
+ a {
46
+ color: var(--naut-color-content-soft);
47
+ text-decoration: none;
48
+ &:hover {
49
+ color: var(--naut-color-content);
50
+ }
51
+ }
52
+ }
53
+
54
+ li + li::before {
55
+ padding-inline-end: 0.5rem;
56
+ color: var(--naut-color-content-soft);
57
+ content: "/";
58
+ opacity: 0.5;
59
+ }
60
+ }
61
+ }
62
+ </style>
@@ -0,0 +1,273 @@
1
+ ---
2
+ import type { Base, Radius, Size } from "../types";
3
+
4
+ type ButtonVariant = "default" | "primary" | "secondary" | "destructive";
5
+ type ButtonSize = Omit<Size, "xl">;
6
+ type ButtonType = "button" | "submit" | "reset";
7
+
8
+ export interface ButtonProps extends Base {
9
+ border?: Omit<Size, "xl"> | "none";
10
+ dark?: boolean;
11
+ href?: string;
12
+ rounded?: Radius;
13
+ size?: ButtonSize;
14
+ type?: ButtonType;
15
+ variant?: ButtonVariant;
16
+ }
17
+
18
+ const {
19
+ href,
20
+ class: className,
21
+ size = "md",
22
+ type = "button",
23
+ variant = "default",
24
+ rounded = "md",
25
+ border = "md",
26
+ pill = false,
27
+ dark = false,
28
+ ...rest
29
+ } = Astro.props as ButtonProps;
30
+
31
+ const classlist = [
32
+ "naut-button",
33
+ `size-${size}`,
34
+ `variant-${variant}`,
35
+ `rounded-${rounded}`,
36
+ `border-${border}`,
37
+ pill && "pill",
38
+ dark && "dark",
39
+ className,
40
+ ];
41
+ ---
42
+
43
+ {href && <a href={href} class:list={classlist} {...rest}><slot /></a>}
44
+ {!href && <button class:list={classlist} type={type} {...rest}><slot /></button>}
45
+
46
+ <style>
47
+ .naut-button {
48
+ position: relative;
49
+ display: inline-flex;
50
+ gap: 0.5rem;
51
+ align-items: center;
52
+ justify-content: center;
53
+
54
+ /* Size */
55
+ height: 2.5rem;
56
+ padding: 0 1rem;
57
+ font-family: inherit;
58
+ font-size: 0.875rem;
59
+ font-weight: 400;
60
+ line-height: 1.5rem;
61
+
62
+ /* Variant default */
63
+ color: var(--naut-color-content);
64
+ white-space: nowrap;
65
+ text-decoration: none;
66
+ cursor: pointer;
67
+ outline: none;
68
+ background: var(--naut-color-base-100);
69
+ border-color: var(--naut-color-base-300);
70
+ border-style: solid;
71
+ border-width: 0.063rem;
72
+ border-radius: 0.5rem;
73
+ box-shadow: 1px 1px 2px 0.5px rgb(from #000 r g b / 0.1);
74
+ transition-duration: 0.1s;
75
+
76
+ &:hover:not(:disabled) {
77
+ background: var(--naut-color-base-200);
78
+ }
79
+
80
+ &:active:not(:disabled) {
81
+ transform: translateY(0.0625rem);
82
+ transition-duration: 0;
83
+ }
84
+
85
+ &.variant-primary {
86
+ color: var(--naut-color-primary-content);
87
+ background: var(--naut-color-primary);
88
+ border-color: var(--naut-color-primary);
89
+
90
+ &:hover:not(:disabled) {
91
+ background: color-mix(in oklch, var(--naut-color-primary), white 35%);
92
+ }
93
+ }
94
+
95
+ &.variant-secondary {
96
+ color: var(--naut-color-secondary-content);
97
+ background: var(--naut-color-secondary);
98
+ border-color: var(--naut-color-secondary);
99
+
100
+ &:hover:not(:disabled) {
101
+ background: color-mix(in oklch, var(--naut-color-secondary), white 35%);
102
+ }
103
+ }
104
+
105
+ &.variant-destructive {
106
+ color: var(--naut-color-destructive-content);
107
+ background: var(--naut-color-destructive);
108
+ border-color: var(--naut-color-destructive);
109
+
110
+ &:hover:not(:disabled) {
111
+ background: color-mix(
112
+ in oklch,
113
+ var(--naut-color-destructive),
114
+ white 25%
115
+ );
116
+ }
117
+ }
118
+
119
+ &.variant-outline,
120
+ &.variant-outline-primary,
121
+ &.variant-outline-secondary {
122
+ color: var(--naut-color-content);
123
+ background: transparent;
124
+ border-color: var(--naut-color-border-strong);
125
+ }
126
+
127
+ /*&.variant-outline:hover:not(:disabled) {
128
+ background: var(--naut-color-base-200);
129
+ }*/
130
+
131
+ &.variant-outline-primary {
132
+ border-color: var(--naut-color-primary);
133
+
134
+ &:hover:not(:disabled) {
135
+ background: rgb(from var(--naut-color-primary) r g b / 0.15);
136
+ }
137
+ }
138
+
139
+ &.variant-outline-secondary {
140
+ border-color: var(--naut-color-secondary);
141
+
142
+ &:hover:not(:disabled) {
143
+ background: rgb(from var(--naut-color-secondary) r g b / 0.15);
144
+ }
145
+ }
146
+
147
+ &.variant-flat {
148
+ background: var(--naut-color-base-100);
149
+ border-color: transparent;
150
+ box-shadow: none;
151
+ }
152
+
153
+ &.variant-ghost {
154
+ background: transparent;
155
+ border: none;
156
+ box-shadow: none;
157
+ }
158
+
159
+ &.variant-link {
160
+ color: var(--naut-color-primary);
161
+ background: transparent;
162
+ border-color: transparent;
163
+ box-shadow: none;
164
+
165
+ &:hover:not(:disabled) {
166
+ text-decoration: underline;
167
+ background: transparent;
168
+ }
169
+ }
170
+
171
+ &.variant-rainbow {
172
+ --naut-rainbow-conic-gradient: conic-gradient(
173
+ from 0turn,
174
+ hsl(110 90% 50%),
175
+ hsl(210 90% 60%),
176
+ hsl(220 70% 60%),
177
+ hsl(30 70% 60%),
178
+ hsl(100 90% 50%)
179
+ );
180
+ background:
181
+ linear-gradient(var(--naut-color-base), var(--naut-color-base-100))
182
+ padding-box,
183
+ var(--naut-rainbow-conic-gradient) border-box;
184
+ border-color: transparent;
185
+ &:hover:not(:disabled) {
186
+ background:
187
+ linear-gradient(var(--naut-color-base), var(--naut-color-base-200))
188
+ padding-box,
189
+ var(--naut-rainbow-conic-gradient) border-box;
190
+ }
191
+ }
192
+
193
+ &:disabled {
194
+ color: rgb(from var(--naut-color-content-soft) r g b / 0.3);
195
+ pointer-events: none;
196
+ background: rgb(from var(--naut-color-base-100) r g b / 0.7);
197
+ border-color: rgb(from var(--naut-color-border) r g b / 0.1);
198
+ box-shadow: none;
199
+ }
200
+
201
+ /* Border thickness */
202
+
203
+ &.border-none {
204
+ border: none;
205
+ }
206
+
207
+ &.border-sm {
208
+ border-width: var(--naut-border-width-sm);
209
+ }
210
+
211
+ &.border-md {
212
+ border-width: var(--naut-border-width-md);
213
+ }
214
+
215
+ &.border-lg {
216
+ border-width: var(--naut-border-width-lg);
217
+ }
218
+
219
+ &.border-xl {
220
+ border-width: var(--naut-border-width-xl);
221
+ }
222
+
223
+ /* Border Radius */
224
+
225
+ &.rounded-none {
226
+ border-radius: 0;
227
+ }
228
+
229
+ &.rounded-sm {
230
+ border-radius: var(--naut-border-radius-sm);
231
+ }
232
+
233
+ &.rounded-md {
234
+ border-radius: var(--naut-border-radius-md);
235
+ }
236
+
237
+ &.rounded-lg {
238
+ border-radius: var(--naut-border-radius-lg);
239
+ }
240
+
241
+ &.rounded-full {
242
+ border-radius: 9999px;
243
+ }
244
+
245
+ /* square */
246
+ &:has(> :only-child):has(> svg:first-child) {
247
+ padding: 0 0.438rem;
248
+ }
249
+
250
+ /* Sizes */
251
+ &.size-sm {
252
+ height: 2rem;
253
+ padding: 0 0.85rem;
254
+ font-size: 0.8rem;
255
+
256
+ /* square */
257
+ &:has(> :only-child):has(> svg:first-child) {
258
+ padding: 0 0.375rem;
259
+ }
260
+ }
261
+
262
+ &.size-lg {
263
+ height: 3rem;
264
+ padding: 0 2.5rem;
265
+ font-size: calc(var(--naut-font-size) * 1.125);
266
+
267
+ /* square */
268
+ &:has(> :only-child):has(> svg:first-child) {
269
+ padding: 0 0.562rem;
270
+ }
271
+ }
272
+ }
273
+ </style>