Skip to content

Commit 889c76b

Browse files
committed
format and fix lint
1 parent 1e7a112 commit 889c76b

File tree

9 files changed

+2804
-2821
lines changed

9 files changed

+2804
-2821
lines changed

README.md

Lines changed: 84 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -69,39 +69,35 @@ values.
6969
import React from 'react';
7070
import { BreakpointProvider, useBreakpoint } from 'my-breakpoint-package';
7171

72+
73+
7274
const breakpoints = {
73-
XS: 0,
74-
SM: 500,
75-
MD: 700,
76-
LG: 900,
77-
XL: 1100,
75+
XS: 0, SM: 500, MD: 700, LG: 900, XL: 1100,
7876
};
7977

8078
const ResponsiveComponent = () => {
8179
const { width, breakpoint, isAtLeast, valueByBreakpoint } = useBreakpoint();
82-
return (
83-
<div>
84-
<p>Current width: {width}px</p>
85-
<p>Active breakpoint: {breakpoint}</p>
86-
<p>Is at least MD: {isAtLeast('MD') ? '✅' : '❌'}</p>
87-
<p>
88-
Mapping: {valueByBreakpoint({
89-
XS: 'Extra Small',
90-
SM: 'Small',
91-
MD: 'Medium',
92-
LG: 'Large',
93-
XL: 'Extra Large'
94-
})}
95-
</p>
96-
</div>
97-
);
80+
return (<div><p>Current
81+
width: {width}
82+
px < /p> < p > Active
83+
breakpoint: {breakpoint}
84+
</p> < p > Is
85+
at
86+
least
87+
MD: {isAtLeast('MD') ? '✅' : '❌'}
88+
</p> < p > Mapping
89+
:
90+
{
91+
valueByBreakpoint({
92+
XS: 'Extra Small', SM: 'Small', MD: 'Medium', LG: 'Large', XL: 'Extra Large'
93+
})
94+
}
95+
</p> < /div>
96+
)
97+
;
9898
};
9999

100-
const App = () => (
101-
<BreakpointProvider breakpoints={breakpoints}>
102-
<ResponsiveComponent />
103-
</BreakpointProvider>
104-
);
100+
const App = () => (<BreakpointProvider breakpoints = { breakpoints } > <ResponsiveComponent / > </BreakpointProvider>);
105101

106102
export default App;
107103
```
@@ -116,30 +112,30 @@ Render content only when specific breakpoint conditions are met.
116112
import React from 'react';
117113
import { BreakpointProvider, BreakpointConditional } from 'my-breakpoint-package';
118114

115+
116+
119117
const breakpoints = {
120-
XS: 0,
121-
SM: 500,
122-
MD: 700,
123-
LG: 900,
124-
XL: 1100,
118+
XS: 0, SM: 500, MD: 700, LG: 900, XL: 1100,
125119
};
126120

127-
const ConditionalComponent = () => (
128-
<div>
129-
<BreakpointConditional isAtLeast="MD">
130-
<p>😊 This content is visible from MD and up.</p>
131-
</BreakpointConditional>
132-
<BreakpointConditional isBelow="LG">
133-
<p>🚀 This content is visible for breakpoints below LG.</p>
134-
</BreakpointConditional>
135-
</div>
136-
);
137-
138-
const App = () => (
139-
<BreakpointProvider breakpoints={breakpoints}>
140-
<ConditionalComponent />
141-
</BreakpointProvider>
142-
);
121+
const ConditionalComponent = () => (<div><BreakpointConditional isAtLeast = "MD" > <p>😊 This
122+
content
123+
is
124+
visible
125+
from
126+
MD
127+
and
128+
up. < /p> < /BreakpointConditional> < BreakpointConditional
129+
isBelow = "LG" > <p>🚀 This
130+
content
131+
is
132+
visible
133+
for breakpoints below
134+
LG. < /p> < /BreakpointConditional> < /div>
135+
)
136+
;
137+
138+
const App = () => (<BreakpointProvider breakpoints = { breakpoints } > <ConditionalComponent / > </BreakpointProvider>);
143139

144140
export default App;
145141
```
@@ -154,37 +150,32 @@ Define your own custom breakpoints – for example, using car sizes:
154150
import React from 'react';
155151
import { BreakpointProvider, useBreakpoint } from 'my-breakpoint-package';
156152

153+
154+
157155
const carBreakpoints = {
158-
Smart: 0,
159-
Mini: 350,
160-
Sedan: 600,
161-
SUV: 900,
162-
Ram: 1200,
156+
Smart: 0, Mini: 350, Sedan: 600, SUV: 900, Ram: 1200,
163157
};
164158

165159
const CarComponent = () => {
166160
const { width, breakpoint, valueByBreakpoint } = useBreakpoint();
167-
return (
168-
<div>
169-
<p>Current width: {width}px</p>
170-
<p>Active car size: {breakpoint}</p>
171-
<p>
172-
Mapping: {valueByBreakpoint({
173-
Smart: '🚗 Smart',
174-
Mini: '🚙 Mini',
175-
Sedan: '🚘 Sedan',
176-
SUV: '🚐 SUV',
177-
Ram: '🚚 Ram'
178-
})}
179-
</p>
180-
</div>
181-
);
161+
return (<div><p>Current
162+
width: {width}
163+
px < /p> < p > Active
164+
car
165+
size: {breakpoint}
166+
</p> < p > Mapping
167+
:
168+
{
169+
valueByBreakpoint({
170+
Smart: '🚗 Smart', Mini: '🚙 Mini', Sedan: '🚘 Sedan', SUV: '🚐 SUV', Ram: '🚚 Ram'
171+
})
172+
}
173+
</p> < /div>
174+
)
175+
;
182176
};
183177

184-
const App = () => ( <BreakpointProvider breakpoints={carBreakpoints}>
185-
<CarComponent />
186-
</BreakpointProvider>
187-
);
178+
const App = () => (<BreakpointProvider breakpoints = { carBreakpoints } > <CarComponent / > </BreakpointProvider>);
188179

189180
export default App;
190181
```
@@ -245,39 +236,35 @@ The `useBreakpoint` hook provides access to the responsive context. It returns a
245236
import React from 'react';
246237
import { BreakpointProvider, useBreakpoint } from 'my-breakpoint-package';
247238

239+
240+
248241
const breakpoints = {
249-
XS: 0,
250-
SM: 500,
251-
MD: 700,
252-
LG: 900,
253-
XL: 1100,
242+
XS: 0, SM: 500, MD: 700, LG: 900, XL: 1100,
254243
};
255244

256245
const ResponsiveComponent = () => {
257246
const { width, breakpoint, isAtLeast, valueByBreakpoint } = useBreakpoint();
258-
return (
259-
<div>
260-
<p>Current width: {width}px</p>
261-
<p>Active breakpoint: {breakpoint}</p>
262-
<p>Is at least MD: {isAtLeast('MD') ? '✅' : '❌'}</p>
263-
<p>
264-
Mapping: {valueByBreakpoint({
265-
XS: 'Extra Small',
266-
SM: 'Small',
267-
MD: 'Medium',
268-
LG: 'Large',
269-
XL: 'Extra Large',
270-
})}
271-
</p>
272-
</div>
273-
);
247+
return (<div><p>Current
248+
width: {width}
249+
px < /p> < p > Active
250+
breakpoint: {breakpoint}
251+
</p> < p > Is
252+
at
253+
least
254+
MD: {isAtLeast('MD') ? '✅' : '❌'}
255+
</p> < p > Mapping
256+
:
257+
{
258+
valueByBreakpoint({
259+
XS: 'Extra Small', SM: 'Small', MD: 'Medium', LG: 'Large', XL: 'Extra Large',
260+
})
261+
}
262+
</p> < /div>
263+
)
264+
;
274265
};
275266

276-
const App = () => (
277-
<BreakpointProvider breakpoints={breakpoints}>
278-
<ResponsiveComponent />
279-
</BreakpointProvider>
280-
);
267+
const App = () => (<BreakpointProvider breakpoints = { breakpoints } > <ResponsiveComponent / > </BreakpointProvider>);
281268

282269
export default App;
283270
```

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,11 @@ export default [
1818
pluginJs.configs.recommended,
1919
...tseslint.configs.recommended,
2020
pluginReact.configs.flat.recommended,
21+
{
22+
settings: {
23+
react: {
24+
version: 'detect',
25+
},
26+
},
27+
},
2128
];

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"scripts": {
1313
"dev": "concurrently \"pnpm build --watch\" \"pnpm storybook\" \"pnpm test\" ",
1414
"build": "tsup",
15-
"lint": "eslint --ext .js,.jsx,.ts,.tsx --fix src",
16-
"lint:ci": "eslint --ext .js,.jsx,.ts,.tsx src",
15+
"lint": "eslint src --fix",
16+
"lint:ci": "eslint src --debug",
1717
"format": "prettier --write src",
1818
"test": "vitest",
1919
"test:ci": "vitest run --coverage",
@@ -40,10 +40,9 @@
4040
}
4141
},
4242
"lint-staged": {
43-
"*.{js,jsx,ts,tsx,json,md}": [
43+
"src/**/*.{js,jsx,ts,tsx,json,md}": [
4444
"prettier --write",
45-
"eslint --fix",
46-
"git add"
45+
"eslint --fix"
4746
]
4847
},
4948
"release-it": {
@@ -118,4 +117,4 @@
118117
"@emotion/styled": "^11.14.0",
119118
"react-resize-detector": "^12.0.2"
120119
}
121-
}
120+
}

0 commit comments

Comments
 (0)