ecmc-design-core 0.0.1 → 0.0.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/README.md +6 -0
- package/dist/atoms/container/Container.svelte +11 -1
- package/dist/atoms/container/constants.js +2 -1
- package/dist/atoms/container/types.d.ts +20 -0
- package/dist/atoms/kbd/Kbd.svelte +43 -0
- package/dist/atoms/kbd/Kbd.svelte.d.ts +4 -0
- package/dist/atoms/kbd/constants.d.ts +7 -0
- package/dist/atoms/kbd/constants.js +8 -0
- package/dist/atoms/kbd/types.d.ts +39 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/molecules/item/Item.svelte +14 -0
- package/dist/molecules/item/Item.svelte.d.ts +4 -0
- package/dist/molecules/item/types.d.ts +7 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Atoms and molecules for the ECMC design system built with Svelte 5.
|
|
4
4
|
|
|
5
|
+
```sh
|
|
6
|
+
bun i ecmc-design-core
|
|
7
|
+
# or
|
|
8
|
+
npm i ecmc-design-core
|
|
9
|
+
```
|
|
10
|
+
|
|
5
11
|
## Overview
|
|
6
12
|
|
|
7
13
|
This is an opinionated component library providing foundational UI components (atoms) and compound components (molecules) for building consistent user interfaces. The library is built with Svelte 5 and includes TypeScript support and Storybook integration.
|
|
@@ -10,11 +10,17 @@
|
|
|
10
10
|
fill = defaultProps.fill!,
|
|
11
11
|
metrics = $bindable(),
|
|
12
12
|
bg = defaultProps.bg!,
|
|
13
|
+
rounding = defaultProps.rounding!,
|
|
13
14
|
...restProps
|
|
14
15
|
}: ContainerProps = $props();
|
|
15
16
|
|
|
16
17
|
let computedClasses = $derived(
|
|
17
|
-
cn(
|
|
18
|
+
cn(
|
|
19
|
+
paddingClasses[padding],
|
|
20
|
+
fill ? 'container--fill' : '',
|
|
21
|
+
bg ? 'container--bg' : '',
|
|
22
|
+
rounding ? 'container--rounding' : ''
|
|
23
|
+
)
|
|
18
24
|
);
|
|
19
25
|
|
|
20
26
|
// Container element reference
|
|
@@ -103,4 +109,8 @@
|
|
|
103
109
|
.container--bg {
|
|
104
110
|
background-color: light-dark(var(--neutral-200), var(--neutral-800));
|
|
105
111
|
}
|
|
112
|
+
|
|
113
|
+
.container--rounding {
|
|
114
|
+
border-radius: var(--rounding-size-1);
|
|
115
|
+
}
|
|
106
116
|
</style>
|
|
@@ -228,10 +228,30 @@ export interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
228
228
|
*/
|
|
229
229
|
padding?: 'none' | 'xsm' | 'sm' | 'md' | 'lg' | 'xl';
|
|
230
230
|
|
|
231
|
+
/**
|
|
232
|
+
* whether to make the container fill its parent dimensions
|
|
233
|
+
* sets width and height to 100%
|
|
234
|
+
*
|
|
235
|
+
* @default false
|
|
236
|
+
*/
|
|
231
237
|
fill?: boolean;
|
|
232
238
|
|
|
239
|
+
/**
|
|
240
|
+
* whether to apply a background color to the container
|
|
241
|
+
* uses neutral-200 in light mode, neutral-800 in dark mode
|
|
242
|
+
*
|
|
243
|
+
* @default false
|
|
244
|
+
*/
|
|
233
245
|
bg?: boolean;
|
|
234
246
|
|
|
247
|
+
/**
|
|
248
|
+
* whether to apply border radius to the container
|
|
249
|
+
* uses var(--rounding-size-1) which is 5px
|
|
250
|
+
*
|
|
251
|
+
* @default false
|
|
252
|
+
*/
|
|
253
|
+
rounding?: boolean;
|
|
254
|
+
|
|
235
255
|
/**
|
|
236
256
|
* Optional bind property to track container element metrics
|
|
237
257
|
*
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../utils/cn.js';
|
|
3
|
+
import type { KbdProps } from './types.js';
|
|
4
|
+
import { defaultProps, kbdSizeClasses } from './constants.js';
|
|
5
|
+
import Centered from '../container/sub/centered.container.svelte';
|
|
6
|
+
|
|
7
|
+
let { children, size = defaultProps.size!, ...restProps }: KbdProps = $props();
|
|
8
|
+
|
|
9
|
+
let computedClasses = $derived(cn(kbdSizeClasses[size]));
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Centered padding="none" fill={false}>
|
|
13
|
+
<kbd class={computedClasses} {...restProps}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</kbd>
|
|
16
|
+
</Centered>
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
kbd {
|
|
20
|
+
background-color: light-dark(var(--neutral-100), var(--neutral-700));
|
|
21
|
+
color: light-dark(var(--neutral-900), var(--neutral-100));
|
|
22
|
+
border-color: light-dark(var(--neutral-300), var(--neutral-500));
|
|
23
|
+
display: inline-block;
|
|
24
|
+
line-height: 1;
|
|
25
|
+
border-radius: var(--rounding-size-1);
|
|
26
|
+
border: 1px solid;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.kbd--small {
|
|
30
|
+
padding: calc(var(--spacing-xsm) * 0.5) var(--spacing-xsm);
|
|
31
|
+
font-size: var(--font-size-0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.kbd--medium {
|
|
35
|
+
padding: var(--spacing-xsm) var(--spacing-sm);
|
|
36
|
+
font-size: var(--font-size-1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.kbd--large {
|
|
40
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
41
|
+
font-size: var(--font-size-2);
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Kbd component
|
|
6
|
+
*
|
|
7
|
+
* Represents keyboard keys or shortcuts with visual styling that resembles
|
|
8
|
+
* physical keyboard keys. Useful for displaying keyboard shortcuts, hotkeys,
|
|
9
|
+
* or keyboard-related instructions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```svelte
|
|
13
|
+
* <Kbd>Ctrl</Kbd>
|
|
14
|
+
*
|
|
15
|
+
* <Kbd variant="dark">
|
|
16
|
+
* Enter
|
|
17
|
+
* </Kbd>
|
|
18
|
+
*
|
|
19
|
+
* <Kbd size="large">
|
|
20
|
+
* ⌘
|
|
21
|
+
* </Kbd>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface KbdProps extends HTMLAttributes<HTMLElement> {
|
|
25
|
+
/**
|
|
26
|
+
* The content to be rendered inside the kbd element
|
|
27
|
+
*/
|
|
28
|
+
children?: Snippet;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Size variant that determines the kbd's dimensions
|
|
32
|
+
* - `small`: Compact size for inline usage
|
|
33
|
+
* - `medium`: Standard size (default)
|
|
34
|
+
* - `large`: Larger size for emphasis
|
|
35
|
+
*
|
|
36
|
+
* @default 'small'
|
|
37
|
+
*/
|
|
38
|
+
size?: 'small' | 'medium' | 'large';
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,7 @@ export { default as Button } from './atoms/button/Button.svelte';
|
|
|
10
10
|
export type { ButtonProps } from './atoms/button/types.js';
|
|
11
11
|
export { default as Input } from './atoms/input/Input.svelte';
|
|
12
12
|
export type { InputProps } from './atoms/input/types.js';
|
|
13
|
+
export { default as Kbd } from './atoms/kbd/Kbd.svelte';
|
|
14
|
+
export type { KbdProps } from './atoms/kbd/types.js';
|
|
15
|
+
export { default as Item } from './molecules/item/Item.svelte';
|
|
16
|
+
export type { ItemProps } from './molecules/item/types.js';
|
package/dist/index.js
CHANGED
|
@@ -9,3 +9,5 @@ export { default as Centered } from './atoms/container/sub/centered.container.sv
|
|
|
9
9
|
export { default as Text } from './atoms/text/Text.svelte';
|
|
10
10
|
export { default as Button } from './atoms/button/Button.svelte';
|
|
11
11
|
export { default as Input } from './atoms/input/Input.svelte';
|
|
12
|
+
export { default as Kbd } from './atoms/kbd/Kbd.svelte';
|
|
13
|
+
export { default as Item } from './molecules/item/Item.svelte';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { HBox, VBox, Text } from '../../index.js';
|
|
3
|
+
import type { ItemProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
let { text, subtitle, action }: ItemProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<HBox bg rounding padding="xsm" justify="space-between">
|
|
9
|
+
<VBox gap="none" padding="none">
|
|
10
|
+
<Text>{text}</Text>
|
|
11
|
+
<Text variant="half">{subtitle}</Text>
|
|
12
|
+
</VBox>
|
|
13
|
+
{@render action?.()}
|
|
14
|
+
</HBox>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ecmc-design-core",
|
|
3
3
|
"description": "Atoms and molecules for ecmc design system",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.2",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Arad Fadaei",
|
|
8
8
|
"url": "https://www.fadaei.dev"
|
|
@@ -82,7 +82,9 @@
|
|
|
82
82
|
"@vitest/coverage-v8": "^4.0.16"
|
|
83
83
|
},
|
|
84
84
|
"keywords": [
|
|
85
|
-
"svelte"
|
|
85
|
+
"svelte",
|
|
86
|
+
"component",
|
|
87
|
+
"atomic"
|
|
86
88
|
],
|
|
87
89
|
"lint-staged": {
|
|
88
90
|
"*": "prettier --write --ignore-unknown",
|