@nightshadeui/core 2.0.0-dev.3

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.
@@ -0,0 +1,13 @@
1
+ import { default as Btn } from './Btn.vue';
2
+ import { default as HGroup } from './HGroup.vue';
3
+ import { default as InputBase } from './InputBase.vue';
4
+ import { default as InputGroup } from './InputGroup.vue';
5
+ import { default as InputSelect } from './InputSelect.vue';
6
+ import { default as InputText } from './InputText.vue';
7
+ import { default as InputTextarea } from './InputTextarea.vue';
8
+ import { default as Sizer } from './Sizer.vue';
9
+ import { default as Tab } from './Tab.vue';
10
+ import { default as TabCap } from './TabCap.vue';
11
+ import { default as Toggle } from './Toggle.vue';
12
+ import { default as VGroup } from './VGroup.vue';
13
+ export { Btn, HGroup, InputBase, InputGroup, InputSelect, InputText, InputTextarea, Sizer, Tab, TabCap, Toggle, VGroup, };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@nightshadeui/core",
3
+ "version": "2.0.0-dev.3",
4
+ "description": "Core Nightshade UI components",
5
+ "author": "Boris Okunskiy",
6
+ "license": "ISC",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": "./dist/core.mjs",
10
+ "./css": "./dist/core.css",
11
+ "./src": "./src/index.ts"
12
+ },
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "src",
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build:watch": "vite build --watch",
20
+ "build": "NODE_ENV=production vite build"
21
+ },
22
+ "peerDependencies": {
23
+ "vue": "^3.5.22"
24
+ }
25
+ }
package/src/Btn.vue ADDED
@@ -0,0 +1,342 @@
1
+ <template>
2
+ <component
3
+ :is="tagName"
4
+ ref="button"
5
+ class="Btn InputElement"
6
+ :class="[
7
+ `Btn-${effectiveStyle.size}`,
8
+ `Btn-${effectiveStyle.kind}`,
9
+ `input-kind-${effectiveStyle.kind}`,
10
+ `Btn-iconPos-${iconPos}`,
11
+ {
12
+ 'Btn-ghost': effectiveStyle.ghost,
13
+ 'Btn-round': effectiveStyle.round,
14
+ 'Btn-outline': effectiveStyle.outline,
15
+ 'Btn-flat': effectiveStyle.flat,
16
+ 'Btn-shadow': effectiveStyle.shadow,
17
+ 'Btn-square': square,
18
+ 'Btn-block': block,
19
+ 'Btn-disabled': disabled || blocked,
20
+ 'Btn-force-focus': forceFocus,
21
+ 'Btn-force-hover': forceHover,
22
+ 'Btn-force-active': forceActive,
23
+ },
24
+ ]"
25
+ :disabled="disabled || blocked"
26
+ :title="title ?? label"
27
+ :href="href"
28
+ @mouseenter="hover = true"
29
+ @mouseleave="hover = false"
30
+ @mousedown="active = true"
31
+ @mouseup="active = false"
32
+ @mouseout="active = false"
33
+ @focusin="focus = true"
34
+ @focusout="focus = false">
35
+
36
+ <slot
37
+ name="icon"
38
+ :hover="hover"
39
+ :blocked="blocked">
40
+ <i
41
+ v-if="icon"
42
+ :class="icon"
43
+ class="Icon" />
44
+ </slot>
45
+
46
+ <span
47
+ v-if="label"
48
+ class="Label">
49
+ {{ label }}
50
+ </span>
51
+
52
+ <slot
53
+ :hover="hover"
54
+ :active="active"
55
+ :blocked="blocked" />
56
+
57
+ </component>
58
+ </template>
59
+
60
+ <script>
61
+ export default {
62
+
63
+ props: {
64
+ tagName: { type: String, default: 'button' },
65
+ href: { type: String },
66
+ label: { type: String },
67
+ title: { type: String },
68
+
69
+ kind: { type: String, default: 'base' },
70
+ size: { type: String, default: 'm' },
71
+ flat: { type: Boolean, default: false },
72
+ shadow: { type: Boolean, default: false },
73
+ outline: { type: Boolean, default: false },
74
+ round: { type: Boolean, default: false },
75
+ ghost: { type: Boolean, default: false },
76
+
77
+ block: { type: Boolean, default: false },
78
+ square: { type: Boolean, default: false },
79
+
80
+ disabled: { type: Boolean, default: false },
81
+ forceFocus: { type: Boolean, default: false },
82
+ forceHover: { type: Boolean, default: false },
83
+ forceActive: { type: Boolean, default: false },
84
+
85
+ icon: { type: String },
86
+ iconPos: { type: String, default: 'left' },
87
+
88
+ hoverOverrides: { type: Object },
89
+ activeOverrides: { type: Object },
90
+ focusOverrides: { type: Object },
91
+ },
92
+
93
+ data() {
94
+ return {
95
+ hover: false,
96
+ active: false,
97
+ focus: false,
98
+ blocked: false,
99
+ };
100
+ },
101
+
102
+ computed: {
103
+
104
+ baseStyle() {
105
+ return {
106
+ kind: this.kind,
107
+ size: this.size,
108
+ flat: this.flat,
109
+ shadow: this.shadow,
110
+ outline: this.outline,
111
+ round: this.round,
112
+ ghost: this.ghost,
113
+ };
114
+ },
115
+
116
+ effectiveStyle() {
117
+ const {
118
+ baseStyle,
119
+ hoverOverrides = {},
120
+ activeOverrides = {},
121
+ focusOverrides = {},
122
+ active,
123
+ hover,
124
+ focus,
125
+ forceActive,
126
+ forceHover,
127
+ forceFocus
128
+ } = this;
129
+ const style = Object.assign({}, baseStyle);
130
+ if (active || forceActive) {
131
+ Object.assign(style, activeOverrides);
132
+ }
133
+ if (hover || forceHover) {
134
+ Object.assign(style, hoverOverrides);
135
+ }
136
+ if (focus || forceFocus) {
137
+ Object.assign(style, focusOverrides);
138
+ }
139
+ return style;
140
+ },
141
+
142
+ },
143
+
144
+ methods: {
145
+
146
+ // TODO add debounce
147
+
148
+ }
149
+
150
+ };
151
+ </script>
152
+
153
+ <style scoped>
154
+ .Btn {
155
+ --Btn-size: var(--input-size);
156
+ --Btn-padding: var(--sp1-5);
157
+ --Btn-gap: var(--sp);
158
+ --Btn-font-size: var(--font-size);
159
+
160
+ --Btn-text-color: var(--input-surface-color-text);
161
+ --Btn-text-shadow: var(--Btn-surface-bottom);
162
+
163
+ --Btn-outline-color: transparent;
164
+
165
+ --Btn-surface: var(--input-surface-color);
166
+ --Btn-surface-top: var(--input-surface-color-top);
167
+ --Btn-surface-bottom: var(--input-surface-color-bottom);
168
+
169
+ --Btn-border-size: 0;
170
+ --Btn-border-color: transparent;
171
+ --Btn-border-radius: var(--border-radius);
172
+
173
+ --Btn-shadow-color: var(--input-shadow-color);
174
+
175
+ --Btn-gradient-x: 50%;
176
+ --Btn-gradient-y: 0%;
177
+ --Btn-gradient-width: 150%;
178
+ --Btn-gradient-height: 150%;
179
+
180
+ -webkit-appearance: none;
181
+ appearance: none;
182
+
183
+ position: relative;
184
+ z-index: var(--input-z);
185
+ margin: 0;
186
+ padding: 0 var(--Btn-padding);
187
+ height: var(--Btn-size);
188
+ line-height: var(--Btn-size);
189
+ box-sizing: border-box;
190
+
191
+ display: inline-flex;
192
+ align-items: center;
193
+ justify-content: flex-start;
194
+ flex-shrink: 0;
195
+ gap: var(--Btn-gap);
196
+
197
+ border: var(--Btn-border-size) solid var(--Btn-border-color);
198
+ border-radius: var(--Btn-border-radius);
199
+
200
+ color: var(--Btn-text-color);
201
+ text-shadow: 0 1px 1px var(--Btn-text-shadow);
202
+ outline: var(--input-outline-size) solid var(--Btn-outline-color);
203
+ outline-offset: var(--input-outline-offset);
204
+ background: radial-gradient(
205
+ var(--Btn-gradient-width) var(--Btn-gradient-height) at var(--Btn-gradient-x) var(--Btn-gradient-y),
206
+ var(--Btn-surface-top),
207
+ var(--Btn-surface-bottom)
208
+ );
209
+
210
+ cursor: pointer;
211
+ user-select: none;
212
+
213
+ font-family: inherit;
214
+ font-size: var(--Btn-font-size);
215
+
216
+ transition: color .3s, outline .3s, filter .3s, border-radius .3s;
217
+ }
218
+
219
+ .Btn::after {
220
+ content: '';
221
+ position: absolute;
222
+ z-index: 1;
223
+ top: 0;
224
+ left: 0;
225
+ width: 100%;
226
+ height: 100%;
227
+ border-radius: var(--Btn-border-radius);
228
+
229
+ background: rgba(127,127,127,.05);
230
+ mix-blend-mode: color-dodge;
231
+ pointer-events: none;
232
+ opacity: 0;
233
+ }
234
+
235
+ .Label {
236
+ line-height: var(--Btn-size);
237
+ white-space: nowrap;
238
+ overflow: hidden;
239
+ text-overflow: ellipsis;
240
+ }
241
+
242
+ .Icon {
243
+ width: var(--sp2);
244
+ display: flex;
245
+ align-items: center;
246
+ justify-content: center;
247
+ font-size: var(--Btn-font-size);
248
+ }
249
+
250
+ .Btn-iconPos-right .Icon {
251
+ order: 100;
252
+ }
253
+
254
+ /* States */
255
+
256
+ .Btn:focus, .Btn:active, .Btn:hover {
257
+ transition: none;
258
+ }
259
+
260
+ .Btn:not(:disabled):hover::after, .Btn.Btn-force-hover::after {
261
+ opacity: 1;
262
+ }
263
+
264
+ .Btn:not(:disabled):focus, .Btn.Btn-force-focus {
265
+ z-index: 10;
266
+ --Btn-outline-color: var(--input-focus-light-color);
267
+ --Btn-border-color: var(--input-focus-medium-color);
268
+ }
269
+
270
+ .Btn:not(:disabled):active, .Btn.Btn-force-active {
271
+ padding-top: 1px;
272
+ box-shadow:
273
+ 0 6px 12px var(--shadow-color-light) inset,
274
+ 0 1px 2px var(--shadow-color-medium) inset;
275
+ }
276
+
277
+ .Btn-disabled {
278
+ opacity: .64;
279
+ filter: saturate(40%);
280
+ cursor: not-allowed;
281
+ }
282
+
283
+ /* Styles */
284
+
285
+ .Btn-round {
286
+ --Btn-border-radius: var(--border-radius-m);
287
+ }
288
+
289
+ .Btn-ghost {
290
+ --Btn-surface: transparent;
291
+ --Btn-surface-top: transparent;
292
+ --Btn-surface-bottom: transparent;
293
+ --Btn-text-color: var(--input-text-color);
294
+ --Btn-text-shadow: none;
295
+ --Btn-shadow-color: var(--shadow-color-light);
296
+ }
297
+
298
+ .Btn-outline {
299
+ --Btn-border-color: var(--input-border-color);
300
+ --Btn-border-size: var(--input-border-size);
301
+ }
302
+
303
+ .Btn-flat {
304
+ --Btn-surface-top: var(--Btn-surface);
305
+ --Btn-surface-bottom: var(--Btn-surface);
306
+ --Btn-text-shadow: none;
307
+ }
308
+
309
+ .Btn-shadow {
310
+ box-shadow:
311
+ 0 1px 1px var(--Btn-shadow-color),
312
+ 0 0 5px -1px var(--shadow-color-light);
313
+ }
314
+
315
+ .Btn-square {
316
+ padding-left: 0;
317
+ padding-right: 0;
318
+ width: var(--Btn-size);
319
+ justify-content: center;
320
+ }
321
+
322
+ .Btn-block {
323
+ flex: 1 1 auto;
324
+ display: flex;
325
+ justify-content: center;
326
+ }
327
+
328
+ /* Sizes */
329
+
330
+ .Btn-large {
331
+ --Btn-size: var(--input-size-l);
332
+ --Btn-font-size: var(--font-size-l);
333
+ --Btn-padding: var(--sp2);
334
+ }
335
+
336
+ .Btn-small {
337
+ --Btn-size: var(--input-size-s);
338
+ --Btn-font-size: var(--font-size-s);
339
+ --Btn-padding: var(--sp);
340
+ --Btn-gap: var(--sp0-5);
341
+ }
342
+ </style>
package/src/HGroup.vue ADDED
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <component
3
+ :is="tagName"
4
+ class="HGroup"
5
+ :class="[
6
+ `HGroup-align-${align}`,
7
+ `HGroup-justify-${justify}`,
8
+ `HGroup-gap-${gap}`,
9
+ {
10
+ 'HGroup-wrap': wrap,
11
+ }
12
+ ]">
13
+ <slot />
14
+ </component>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+
20
+ props: {
21
+ tagName: { type: String, default: 'div' },
22
+ align: { type: String, default: 'center' },
23
+ justify: { type: String },
24
+ gap: { type: String, default: 's' },
25
+ wrap: { type: Boolean, default: false },
26
+ }
27
+
28
+ };
29
+ </script>
30
+
31
+ <style scoped>
32
+ .HGroup {
33
+ display: flex;
34
+ flex-flow: row nowrap;
35
+ }
36
+
37
+ .HGroup-align-stretch { align-items: stretch; }
38
+ .HGroup-align-baseline { align-items: baseline; }
39
+ .HGroup-align-center { align-items: center; }
40
+ .HGroup-align-start { align-items: flex-start; }
41
+ .HGroup-align-end { align-items: flex-end; }
42
+
43
+ .HGroup-justify-center { justify-content: center; }
44
+ .HGroup-justify-start { justify-content: flex-start; }
45
+ .HGroup-justify-end { justify-content: flex-end; }
46
+ .HGroup-justify-space-around { justify-content: space-around; }
47
+ .HGroup-justify-space-between { justify-content: space-between; }
48
+
49
+ .HGroup-gap-xxs { gap: var(--sp-xxs) }
50
+ .HGroup-gap-xs { gap: var(--sp-xs) }
51
+ .HGroup-gap-s { gap: var(--sp-s) }
52
+ .HGroup-gap-m { gap: var(--sp-m) }
53
+ .HGroup-gap-l { gap: var(--sp-l) }
54
+ .HGroup-gap-xl { gap: var(--sp-xl) }
55
+ .HGroup-gap-xxl { gap: var(--sp-xxl) }
56
+
57
+ .HGroup-gap-0 { gap: 0 }
58
+ .HGroup-gap-0-25 { gap: var(--sp0-25) }
59
+ .HGroup-gap-0-5 { gap: var(--sp0-5) }
60
+ .HGroup-gap-1 { gap: var(--sp1) }
61
+ .HGroup-gap-1-5 { gap: var(--sp1-5) }
62
+ .HGroup-gap-2 { gap: var(--sp2) }
63
+ .HGroup-gap-2-5 { gap: var(--sp2-5) }
64
+ .HGroup-gap-3 { gap: var(--sp3) }
65
+ .HGroup-gap-4 { gap: var(--sp4) }
66
+ .HGroup-gap-5 { gap: var(--sp5) }
67
+ .HGroup-gap-6 { gap: var(--sp6) }
68
+ .HGroup-gap-7 { gap: var(--sp7) }
69
+ .HGroup-gap-8 { gap: var(--sp8) }
70
+ .HGroup-gap-9 { gap: var(--sp9) }
71
+ .HGroup-gap-10 { gap: var(--sp10) }
72
+ .HGroup-gap-12 { gap: var(--sp12) }
73
+ .HGroup-gap-16 { gap: var(--sp16) }
74
+ .HGroup-gap-24 { gap: var(--sp24) }
75
+ .HGroup-gap-32 { gap: var(--sp32) }
76
+
77
+ .HGroup-wrap { flex-wrap: wrap; }
78
+ </style>