Skip to content

Commit bbd1e17

Browse files
committed
refactor(eds-core-react): πŸ”§ Input - rename styles.css to index.css
- Rename src/styles.css to src/index.css for better naming convention - Rename build outputs: styles.css β†’ index.css, styles.min.css β†’ index.min.css - Update package.json exports to use index.css naming - Update all import references in src/index.ts and .storybook/preview.mjs - Update rollup.config.js to build index.css files - Update CSS_ARCHITECTURE.md documentation - Rebuild CSS files with new naming
1 parent 1167555 commit bbd1e17

File tree

11 files changed

+35
-33
lines changed

11 files changed

+35
-33
lines changed

β€Žpackages/eds-core-react/.storybook/preview.mjsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import './preview.css'
2-
import '../src/styles.css'
2+
import '../src/index.css'
33

44
const preview = {
55
viewMode: 'docs',

β€Žpackages/eds-core-react/CSS_ARCHITECTURE.mdβ€Ž

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,46 @@
22

33
## Overview
44

5-
Component CSS is centralized in `src/styles.css` to prevent duplicate imports and enable automatic tree-shaking.
5+
Component CSS is centralized in `src/index.css` to prevent duplicate imports and enable automatic tree-shaking.
66

77
## Structure
88

99
```
1010
src/
11-
β”œβ”€β”€ styles.css # Imports all component CSS
12-
β”œβ”€β”€ index.ts # Imports styles.css once
11+
β”œβ”€β”€ index.css # Imports all component CSS
12+
β”œβ”€β”€ index.ts # Imports index.css once
1313
└── components/
1414
└── Input/
1515
β”œβ”€β”€ Input.new.tsx # No CSS import
16-
└── Input.new.css # Styles defined here
16+
└── input.new.css # Styles defined here
1717
```
1818

1919
## How It Works
2020

2121
1. Component CSS files contain the styles
22-
2. `src/styles.css` imports all component CSS with `@import`
23-
3. `src/index.ts` imports `styles.css` once
22+
2. `src/index.css` imports all component CSS with `@import`
23+
3. `src/index.ts` imports `index.css` once
2424
4. Users get all CSS automatically when importing components
2525

2626
## Adding Components
2727

2828
When creating a component with CSS:
2929

30-
1. Create `Button.new.css` in component directory
31-
2. Add to `src/styles.css`:
30+
1. Create `button.new.css` in component directory
31+
2. Add to `src/index.css`:
3232
```css
33-
@import './components/Button/Button.new.css';
33+
@import './components/Button/button.new.css';
3434
```
3535
3. **Never** import CSS in `.tsx` files
3636

3737
## Build
3838

3939
Rollup builds CSS with PostCSS to bundle all `@import` statements:
4040

41-
- **Input**: `src/styles.css`
42-
- **Output**:
43-
- `build/styles.css` (3.5KB formatted)
44-
- `build/styles.min.css` (2.1KB minified)
41+
- **Input**: `src/index.css`
42+
- **Output**:
43+
- `build/index.css` (3.5KB formatted)
44+
- `build/index.min.css` (2.1KB minified)
4545

4646
## Usage
4747

@@ -54,18 +54,20 @@ import { InputNew } from '@equinor/eds-core-react'
5454
Or import CSS separately if needed:
5555

5656
```tsx
57-
import '@equinor/eds-core-react/styles.css' // Development
58-
import '@equinor/eds-core-react/styles.min.css' // Production
57+
import '@equinor/eds-core-react/index.css' // Development
58+
import '@equinor/eds-core-react/index.min.css' // Production
5959
```
6060
6161
## Configuration
6262
6363
**package.json**:
64+
6465
- `"sideEffects": ["**/*.css"]` -- Preserves CSS during tree-shaking
6566
- `"files": ["dist/*", "build/*"]` -- Publishes JS and CSS
66-
- Exports CSS at `./styles.css` and `./styles.min.css`
67+
- Exports CSS at `./index.css` and `./index.min.css`
6768
6869
**Storybook** (`.storybook/preview.mjs`):
70+
6971
```javascript
70-
import '../src/styles.css' // Global component styles
72+
import '../src/index.css' // Global component styles
7173
```

β€Žpackages/eds-core-react/build/styles.cssβ€Ž renamed to β€Žpackages/eds-core-react/build/index.cssβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
}
102102

103103
/* Force neutral colors for adornments even when parent has invalid state */
104-
[data-color-appearance] .eds-adornment {
104+
.eds-input[data-color-appearance] .eds-adornment {
105105
color: var(--eds-color-text-subtle);
106106
}
107107

β€Žpackages/eds-core-react/build/styles.min.cssβ€Ž renamed to β€Žpackages/eds-core-react/build/index.min.cssβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackages/eds-core-react/package.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"import": "./dist/esm/index.js",
3333
"require": "./dist/eds-core-react.cjs"
3434
},
35-
"./styles.css": "./build/styles.css",
36-
"./styles.min.css": "./build/styles.min.css"
35+
"./index.css": "./build/index.css",
36+
"./index.min.css": "./build/index.min.css"
3737
},
3838
"scripts": {
3939
"build": "rollup -c && tsc -p tsconfig.build.json",

β€Žpackages/eds-core-react/rollup.config.jsβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export default [
5858
],
5959
},
6060
{
61-
input: './src/styles.css',
61+
input: './src/index.css',
6262
plugins: [
6363
postcss({
6464
extensions: ['.css'],
65-
extract: 'styles.css',
65+
extract: 'index.css',
6666
minimize: false,
6767
sourceMap: false,
6868
plugins: [postcssImport()],
@@ -74,11 +74,11 @@ export default [
7474
},
7575
},
7676
{
77-
input: './src/styles.css',
77+
input: './src/index.css',
7878
plugins: [
7979
postcss({
8080
extensions: ['.css'],
81-
extract: 'styles.min.css',
81+
extract: 'index.min.css',
8282
minimize: true,
8383
sourceMap: false,
8484
plugins: [postcssImport()],

β€Žpackages/eds-core-react/src/components/Input/Input.new.docs.mdxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as ComponentStories from './Input.new.stories'
1010

1111
This component uses the **dynamic color approach** from `@equinor/eds-tokens`, allowing semantic context changes via the `data-color-appearance` attribute without modifying component code.
1212

13-
Intended to use if you need more flexibility than the wrapped TextField or select components give.
13+
Intended to be used if you need more flexibility than the wrapped TextField or select components provide.
1414

1515
<Links
1616
ariaUrl="https://www.w3.org/TR/wai-aria-1.1/#input"

β€Žpackages/eds-core-react/src/components/Input/Input.new.stories.tsxβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export const WithAdornments: StoryFn<InputProps> = () => {
224224
rightAdornments={
225225
<>
226226
unit
227-
<Icon data={anchor} size={18}></Icon>
227+
<Icon data={anchor} size={18} />
228228
</>
229229
}
230230
/>
@@ -244,7 +244,7 @@ export const WithAdornments: StoryFn<InputProps> = () => {
244244
rightAdornments={
245245
<>
246246
unit
247-
<Icon data={anchor} size={18}></Icon>
247+
<Icon data={anchor} size={18} />
248248
</>
249249
}
250250
/>
@@ -267,7 +267,7 @@ export const WithAdornments: StoryFn<InputProps> = () => {
267267
rightAdornments={
268268
<>
269269
unit
270-
<Icon data={anchor} size={18}></Icon>
270+
<Icon data={anchor} size={18} />
271271
</>
272272
}
273273
/>
@@ -287,7 +287,7 @@ export const WithAdornments: StoryFn<InputProps> = () => {
287287
rightAdornments={
288288
<>
289289
unit
290-
<Icon data={anchor} size={18}></Icon>
290+
<Icon data={anchor} size={18} />
291291
</>
292292
}
293293
/>

β€Žpackages/eds-core-react/src/components/Input/input.new.cssβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898

9999
/* Force neutral colors for adornments even when parent has invalid state */
100-
[data-color-appearance] .eds-adornment {
100+
.eds-input[data-color-appearance] .eds-adornment {
101101
color: var(--eds-color-text-subtle);
102102
}
103103

0 commit comments

Comments
Β (0)