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 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(paddingClasses[padding], fill ? 'container--fill' : '', bg ? 'container--bg' : '')
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>
@@ -4,7 +4,8 @@
4
4
  export const defaultProps = {
5
5
  padding: 'md',
6
6
  fill: false,
7
- bg: false
7
+ bg: false,
8
+ rounding: false
8
9
  };
9
10
  /**
10
11
  * CSS class mappings for padding variants
@@ -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,4 @@
1
+ import type { KbdProps } from './types.js';
2
+ declare const Kbd: import("svelte").Component<KbdProps, {}, "">;
3
+ type Kbd = ReturnType<typeof Kbd>;
4
+ export default Kbd;
@@ -0,0 +1,7 @@
1
+ import type { KbdProps } from './types.js';
2
+ export declare const defaultProps: Partial<KbdProps>;
3
+ export declare const kbdSizeClasses: {
4
+ readonly small: "kbd--small";
5
+ readonly medium: "kbd--medium";
6
+ readonly large: "kbd--large";
7
+ };
@@ -0,0 +1,8 @@
1
+ export const defaultProps = {
2
+ size: 'small'
3
+ };
4
+ export const kbdSizeClasses = {
5
+ small: 'kbd--small',
6
+ medium: 'kbd--medium',
7
+ large: 'kbd--large'
8
+ };
@@ -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>
@@ -0,0 +1,4 @@
1
+ import type { ItemProps } from './types.js';
2
+ declare const Item: import("svelte").Component<ItemProps, {}, "">;
3
+ type Item = ReturnType<typeof Item>;
4
+ export default Item;
@@ -0,0 +1,7 @@
1
+ import type { Snippet } from 'svelte';
2
+
3
+ export interface ItemProps {
4
+ text: string;
5
+ subtitle?: string;
6
+ action?: Snippet;
7
+ }
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.1",
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",