Skip to content

Commit 54bd611

Browse files
authored
Merge pull request #101 from etchteam/feature/abbr-diamond-round-2
feat!: abbreviate diamond to dmd
2 parents dc201d4 + 2917a20 commit 54bd611

116 files changed

Lines changed: 2116 additions & 2037 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.cjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
ignorePatterns: ['dist', 'node_modules'],
23
plugins: ['lit-a11y', 'spellcheck'],
34
extends: ['@etchteam', 'plugin:lit-a11y/recommended'],
45
rules: {
@@ -19,6 +20,33 @@ module.exports = {
1920
'center',
2021
'etc',
2122
'flexbox',
23+
'StoryObj',
24+
'dmd',
25+
'obj',
26+
'i',
27+
'keyframes',
28+
'srgb',
29+
'alt',
30+
'xl',
31+
'xxl',
32+
'xxxl',
33+
'xxxxl',
34+
'sr',
35+
'textarea',
36+
'Textarea',
37+
'calc',
38+
'unstyled',
39+
'svg',
40+
'colors',
41+
'div',
42+
'formgroup',
43+
'dialog',
44+
'unobserve',
45+
'bp',
46+
'eee',
47+
'centers',
48+
'centered',
49+
'gs',
2250
],
2351
},
2452
],

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ about: Create a report to help us improve
88
A clear and concise description of what the bug is.
99

1010
**To Reproduce**
11-
Steps to reproduce the behavior:
11+
Steps to reproduce the behaviour:
1212
1. Go to '...'
1313
2. Click on '....'
1414
3. Scroll down to '....'
1515
4. See error
1616

17-
**Expected behavior**
17+
**Expected behaviour**
1818
A clear and concise description of what you expected to happen.
1919

2020
**Screenshots**

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ jobs:
5353
VALIDATE_JSX: false
5454
VALIDATE_TSX: false
5555
VALIDATE_TYPESCRIPT_STANDARD: false
56-
FILTER_REGEX_EXCLUDE: preview-head.html
56+
FILTER_REGEX_EXCLUDE: (preview-head.html|CLAUDE.md|bug_report.md)

.storybook/preview.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,21 @@ const preview: Preview = {
122122
},
123123
designTokenTables: {
124124
collections: {
125-
'diamond-radius': 'radius',
126-
'diamond-color': 'color',
127-
'diamond-spacing': 'spacing',
128-
'diamond-button-gap': 'spacing',
129-
'diamond-font-line-height': 'line-height',
130-
'diamond-font-size': 'font-size',
131-
'diamond-font-weight': 'font-weight',
132-
'diamond-theme': 'color',
133-
'diamond-button-primary': 'color',
134-
'diamond-button-secondary': 'color',
135-
'diamond-button-text': 'color',
136-
'diamond-font-family': 'font-family',
137-
'diamond-input-radio-checkbox-padding': 'spacing',
138-
'diamond-input-padding': 'spacing',
139-
'diamond-shadow': 'shadow',
125+
'dmd-radius': 'radius',
126+
'dmd-color': 'color',
127+
'dmd-spacing': 'spacing',
128+
'dmd-button-gap': 'spacing',
129+
'dmd-font-line-height': 'line-height',
130+
'dmd-font-size': 'font-size',
131+
'dmd-font-weight': 'font-weight',
132+
'dmd-theme': 'color',
133+
'dmd-button-primary': 'color',
134+
'dmd-button-secondary': 'color',
135+
'dmd-button-text': 'color',
136+
'dmd-font-family': 'font-family',
137+
'dmd-input-radio-checkbox-padding': 'spacing',
138+
'dmd-input-padding': 'spacing',
139+
'dmd-shadow': 'shadow',
140140
},
141141
tokens: [
142142
borderTokens,

.storybook/styles.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
}
44

55
docs-placeholder {
6-
background: var(--diamond-color-grey-50);
7-
border: dotted 1px var(--diamond-theme-border-color);
8-
border-radius: var(--diamond-radius-sm);
6+
background: var(--dmd-color-grey-50);
7+
border: dotted 1px var(--dmd-theme-border-color);
8+
border-radius: var(--dmd-radius-sm);
99
display: block;
10-
padding: var(--diamond-spacing-lg);
10+
padding: var(--dmd-spacing-lg);
1111
text-align: left;
1212
}

CLAUDE.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Diamond UI is a lightweight design system built with Lit web components, design tokens, and CSS. Components use minimal JavaScript and follow the "CSS web components" methodology (see [https://etch.co/blog/css-web-components](https://etch.co/blog/css-web-components)). The library is framework-agnostic and can be installed in any web project.
8+
9+
**Component naming convention**: All components are prefixed with `dmd-` (abbreviated from "diamond"). For example: `dmd-grid`, `dmd-card`, `dmd-button`.
10+
11+
## Development Commands
12+
13+
### Running the project
14+
```bash
15+
npm start # Start Vite dev server
16+
npm run storybook # Start Storybook on port 6006
17+
```
18+
19+
### Building
20+
```bash
21+
npm run build # Build components and styles with Rollup
22+
npm run build-storybook # Build Storybook static site
23+
```
24+
25+
### Code quality
26+
```bash
27+
npm run lint:css # Lint CSS files with Stylelint
28+
npm run lint:js # Lint JS with eslint
29+
```
30+
31+
Note: There are no test scripts configured yet (`npm test` will fail).
32+
33+
## Architecture
34+
35+
### Component Categories
36+
37+
Components are organized into four categories under `components/`:
38+
39+
1. **canvas/** - Layout containers (e.g., `Card`, `Section`)
40+
2. **composition/** - Layout and structural components (e.g., `Grid`, `FormGroup`, `Dialog`, `Hidden`)
41+
3. **content/** - Content display components (e.g., `Icon`, `Text`, `List`, `LoadingButton`)
42+
4. **control/** - Interactive form components (e.g., `Button`, `Input`, `RadioCheckbox`, `Link`)
43+
44+
### Component Types
45+
46+
Diamond UI uses two component approaches:
47+
48+
1. **Lit Components** - JavaScript web components built with Lit
49+
- Located in `.ts` files
50+
- Use `@customElement` decorator
51+
- Extend `LitElement`
52+
- Example: `Icon`, `LoadingButton`
53+
54+
2. **CSS Web Components** - Pure CSS components with only TypeScript interfaces
55+
- Have a `.ts` file that ONLY exports TypeScript types/interfaces (no implementation)
56+
- All styling and behaviour in corresponding `.css` file
57+
- Example: `Card`, `Button`, `Grid`
58+
59+
### Component Structure Pattern
60+
61+
Each component follows this structure:
62+
63+
```text
64+
components/[category]/[ComponentName]/
65+
├── ComponentName.ts # Lit component OR type definitions only
66+
├── ComponentName.css # Component styles (always present)
67+
└── ComponentName.stories.ts # Storybook stories
68+
```
69+
70+
**Key files:**
71+
- `ComponentName.ts` exports an interface `[ComponentName]Attributes` defining the component's props
72+
- All components declare global types for both vanilla HTML and React JSX usage
73+
- React type declarations use `JSXCustomElement<T>` helper type from `types/jsx-custom-element.ts`
74+
75+
Example interface pattern:
76+
```typescript
77+
export interface CardAttributes {
78+
border?: string | boolean;
79+
padding?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'none';
80+
}
81+
82+
declare global {
83+
interface HTMLElementTagNameMap {
84+
'dmd-card': CardAttributes;
85+
}
86+
}
87+
88+
declare module 'react' {
89+
namespace JSX {
90+
interface IntrinsicElements {
91+
'dmd-card': JSXCustomElement<CardAttributes>;
92+
}
93+
}
94+
}
95+
```
96+
97+
### Design Tokens
98+
99+
All design tokens are defined as CSS custom properties in `styles/tokens/`:
100+
- `border.css` - Border styles
101+
- `button.css` - Button-specific tokens
102+
- `color.css` - Color palette
103+
- `font.css` - Typography
104+
- `icon.css` - Icon sizing
105+
- `input.css` - Form input styles
106+
- `radius.css` - Border radius values
107+
- `shadow.css` - Box shadows
108+
- `spacing.css` - Spacing scale
109+
- `theme.css` - Theme variables
110+
- `transition.css` - Animation timings
111+
- `wrap.css` - Container widths
112+
113+
Tokens can be overridden by defining CSS custom properties on `:root`.
114+
115+
### Build Tool
116+
117+
Rollup is configured to output three bundles:
118+
1. **JavaScript components** - All `.ts` files from `components/` (excluding `.stories.ts`)
119+
2. **Type definitions** - Generated `.d.ts` files
120+
3. **Styles** - `diamond-ui.css` bundle that includes all component styles via PostCSS glob imports
121+
122+
The build:
123+
- Uses `@rollup/plugin-typescript` for TypeScript compilation
124+
- Uses `rollup-plugin-postcss` with `postcss-import-ext-glob` to bundle CSS
125+
- Maintains directory structure in `dist/`
126+
- Copies individual token files to `dist/styles/` for granular imports
127+
128+
### Shared Utilities
129+
130+
Reusable code in `lib/`:
131+
- `pulse.ts` - Lit CSS for loading/skeleton animations
132+
- `breakpoints.ts` - Responsive breakpoint definitions
133+
- `css-map.ts` - Utility for mapping props to CSS classes
134+
135+
### Interactive Elements Pattern
136+
137+
When custom elements need to be interactive (clickable/tappable), wrap them in semantic HTML elements (`<a>`, `<button>`, or `<label>`).
138+
139+
The base CSS (`styles/base/interactive.css`) hides the styling of these wrappers when they contain:
140+
- `dmd-card` components
141+
- Elements with `data-interactive` attribute
142+
143+
This preserves accessibility while allowing visual customization.
144+
145+
### Theming
146+
147+
Diamond supports custom theming via CSS custom properties. No production themes are included by default. Theme styles are defined in `styles/themes.css`.
148+
149+
Theme variables follow the pattern `--dmd-theme-[property]` and can be scoped to specific components or containers.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import '@etchteam/diamond-ui/composition/Grid/Grid';
2727
And then used in HTML (or React, Vue, Angular, etc)
2828

2929
```html
30-
<diamond-grid>
31-
<diamond-grid-item>
30+
<dmd-grid>
31+
<dmd-grid-item>
3232
Grid content
33-
</diamond-grid-item>
34-
</diamond-grid>
33+
</dmd-grid-item>
34+
</dmd-grid>
3535
```
3636

3737
## Configure

components/canvas/Card/Card.css

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
diamond-card {
2-
background: var(--diamond-theme-background);
1+
dmd-card {
2+
background: var(--dmd-theme-background);
33
border: 0 none;
4-
color: var(--diamond-theme-color);
4+
color: var(--dmd-theme-color);
55
display: block;
6-
padding: var(--diamond-spacing);
7-
transition: border-color var(--diamond-transition);
6+
padding: var(--dmd-spacing);
7+
transition: border-color var(--dmd-transition);
88

99
&[shadow] {
10-
box-shadow: var(--diamond-shadow);
10+
box-shadow: var(--dmd-shadow);
1111
}
1212

1313
&[muted] {
14-
background: var(--diamond-theme-background-muted);
14+
background: var(--dmd-theme-background-muted);
1515
}
1616

1717
&[radius] {
18-
border-radius: var(--diamond-radius);
18+
border-radius: var(--dmd-radius);
1919
overflow: hidden;
2020
}
2121

2222
&[padding='xs'] {
23-
padding: var(--diamond-spacing-xs);
23+
padding: var(--dmd-spacing-xs);
2424
}
2525

2626
&[padding='sm'] {
27-
padding: var(--diamond-spacing-sm);
27+
padding: var(--dmd-spacing-sm);
2828
}
2929

3030
&[padding='lg'] {
31-
padding: var(--diamond-spacing-lg);
31+
padding: var(--dmd-spacing-lg);
3232
}
3333

3434
&[padding='xl'] {
35-
padding: var(--diamond-spacing-xl);
35+
padding: var(--dmd-spacing-xl);
3636
}
3737

3838
&[padding='fluid-sm'] {
39-
padding: var(--diamond-spacing-fluid-sm);
39+
padding: var(--dmd-spacing-fluid-sm);
4040
}
4141

4242
&[padding='fluid'] {
43-
padding: var(--diamond-spacing-fluid);
43+
padding: var(--dmd-spacing-fluid);
4444
}
4545

4646
&[padding='fluid-lg'] {
47-
padding: var(--diamond-spacing-fluid-lg);
47+
padding: var(--dmd-spacing-fluid-lg);
4848
}
4949

5050
&[padding='none'] {
5151
padding: 0;
5252
}
5353

5454
&[border] {
55-
border: 1px solid var(--diamond-theme-border-color);
55+
border: 1px solid var(--dmd-theme-border-color);
5656
}
5757

5858
@media (hover: hover) {
5959
&[border][href]:hover {
60-
border-color: var(--diamond-theme-border-color-hover);
60+
border-color: var(--dmd-theme-border-color-hover);
6161
}
6262
}
6363
}
@@ -66,8 +66,8 @@ button,
6666
a {
6767
&:hover,
6868
&:focus-visible {
69-
diamond-card {
70-
border-color: var(--diamond-theme-border-color-hover);
69+
dmd-card {
70+
border-color: var(--dmd-theme-border-color-hover);
7171
}
7272
}
7373
}

0 commit comments

Comments
 (0)