colibri-ui 0.8.77 → 0.8.78
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/Modal/index.js +1 -1
- package/README.md +59 -0
- package/Theme/breakpoints.d.ts +20 -16
- package/Theme/breakpoints.js +21 -32
- package/Theme/index.d.ts +2 -0
- package/Theme/index.js +3 -0
- package/esm/Modal/index.js +1 -1
- package/esm/Theme/breakpoints.d.ts +20 -16
- package/esm/Theme/breakpoints.js +20 -26
- package/esm/Theme/index.d.ts +2 -0
- package/esm/hooks/useMediaSizes/index.d.ts +2 -2
- package/esm/hooks/useMediaSizes/index.js +2 -2
- package/esm/index.d.ts +2 -1
- package/esm/index.js +1 -0
- package/hooks/useMediaSizes/index.d.ts +2 -2
- package/hooks/useMediaSizes/index.js +1 -1
- package/index.d.ts +2 -1
- package/index.js +3 -0
- package/package.json +1 -1
package/Modal/index.js
CHANGED
|
@@ -51,7 +51,7 @@ var ModalRoot = function ModalRoot(_ref) {
|
|
|
51
51
|
var parentContainer = withinParent ? parentModal === null || parentModal === void 0 ? void 0 : parentModal.container : undefined;
|
|
52
52
|
var isContained = Boolean(parentContainer);
|
|
53
53
|
var isDesktop = index$4.useMediaSizes(function (bp) {
|
|
54
|
-
return bp.up("
|
|
54
|
+
return bp.up("lg");
|
|
55
55
|
});
|
|
56
56
|
var titleId = React.useId();
|
|
57
57
|
var _useState3 = React.useState(0),
|
package/README.md
CHANGED
|
@@ -131,6 +131,65 @@ If you add a theme inside the library itself, create both layers:
|
|
|
131
131
|
|
|
132
132
|
Then export it from `src/components/Theme/index.tsx` and update `scripts/variables.ts` if you want a generated CSS variables file in the package build.
|
|
133
133
|
|
|
134
|
+
## Breakpoints
|
|
135
|
+
|
|
136
|
+
Colibri UI uses one fixed set of breakpoints, shared with the apps that use the kit.
|
|
137
|
+
|
|
138
|
+
| Name | Value | px |
|
|
139
|
+
| ----- | ------- | ---- |
|
|
140
|
+
| `sm` | `40rem` | 640 |
|
|
141
|
+
| `md` | `48rem` | 768 |
|
|
142
|
+
| `lg` | `64rem` | 1024 |
|
|
143
|
+
| `xl` | `80rem` | 1280 |
|
|
144
|
+
| `2xl` | `96rem` | 1536 |
|
|
145
|
+
|
|
146
|
+
The values match the Tailwind CSS defaults on purpose, because they are an industry standard. Tailwind is not a dependency of Colibri UI.
|
|
147
|
+
|
|
148
|
+
Rules:
|
|
149
|
+
|
|
150
|
+
- **Mobile first.** Base styles are for screens narrower than `sm`. There is no `xs`.
|
|
151
|
+
- **rem, not px.** Layout follows the user's browser font size.
|
|
152
|
+
- **Range syntax only.** Write `(width >= 48rem)` and `(width < 48rem)`. Do not use `min-width` / `max-width` or `- 1px` arithmetic: each edge belongs to exactly one side.
|
|
153
|
+
|
|
154
|
+
### CSS
|
|
155
|
+
|
|
156
|
+
CSS cannot read variables inside media queries, so write the value as a literal:
|
|
157
|
+
|
|
158
|
+
```css
|
|
159
|
+
.card {
|
|
160
|
+
padding: var(--space-4);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@media (width >= 64rem) {
|
|
164
|
+
.card {
|
|
165
|
+
padding: var(--space-6);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Inside the kit, a test and a stylelint rule reject `min-width` / `max-width` and any width value outside the table.
|
|
171
|
+
|
|
172
|
+
### JavaScript
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { BREAKPOINTS, media, useMediaSizes } from "colibri-ui";
|
|
176
|
+
|
|
177
|
+
BREAKPOINTS.md; // "48rem"
|
|
178
|
+
media.up("md"); // "(width >= 48rem)"
|
|
179
|
+
media.down("md"); // "(width < 48rem)"
|
|
180
|
+
media.between("md", "lg"); // "(48rem <= width < 64rem)"
|
|
181
|
+
|
|
182
|
+
window.matchMedia(media.up("lg")).matches;
|
|
183
|
+
|
|
184
|
+
// in a component
|
|
185
|
+
const isDesktop = useMediaSizes((bp) => bp.up("lg"));
|
|
186
|
+
|
|
187
|
+
// CSS-in-JS: add the @media prefix yourself
|
|
188
|
+
const css = `@media ${media.down("sm")} { … }`;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`BREAKPOINTS` and `media` are also exported from `colibri-ui/Theme`.
|
|
192
|
+
|
|
134
193
|
## License
|
|
135
194
|
|
|
136
195
|
MIT
|
package/Theme/breakpoints.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
sm:
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Breakpoints shared with the apps that use the kit.
|
|
3
|
+
* The values match the Tailwind CSS defaults on purpose; Tailwind is not a dependency.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BREAKPOINTS: {
|
|
6
|
+
readonly sm: "40rem";
|
|
7
|
+
readonly md: "48rem";
|
|
8
|
+
readonly lg: "64rem";
|
|
9
|
+
readonly xl: "80rem";
|
|
10
|
+
readonly "2xl": "96rem";
|
|
8
11
|
};
|
|
9
|
-
export type BreakpointName = keyof
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
up: (
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export type BreakpointName = keyof typeof BREAKPOINTS;
|
|
13
|
+
export type Media = {
|
|
14
|
+
/** `(width >= <name>)` */
|
|
15
|
+
up: (name: BreakpointName) => string;
|
|
16
|
+
/** `(width < <name>)` */
|
|
17
|
+
down: (name: BreakpointName) => string;
|
|
18
|
+
/** `(<from> <= width < <to>)` */
|
|
19
|
+
between: (from: BreakpointName, to: BreakpointName) => string;
|
|
15
20
|
};
|
|
16
|
-
|
|
17
|
-
declare const
|
|
18
|
-
export default Breakpoints;
|
|
21
|
+
/** Bare media queries, usable in `window.matchMedia`. Prefix with `@media ` in CSS-in-JS. */
|
|
22
|
+
export declare const media: Media;
|
package/Theme/breakpoints.js
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
xs: 320
|
|
19
|
-
},
|
|
20
|
-
up: function up(breakpoint) {
|
|
21
|
-
var isMedia = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
22
|
-
return "".concat(isMedia ? "@media " : "", "(min-width: ").concat(this.values[breakpoint], "px)");
|
|
3
|
+
/**
|
|
4
|
+
* Breakpoints shared with the apps that use the kit.
|
|
5
|
+
* The values match the Tailwind CSS defaults on purpose; Tailwind is not a dependency.
|
|
6
|
+
*/
|
|
7
|
+
var BREAKPOINTS = {
|
|
8
|
+
sm: "40rem",
|
|
9
|
+
md: "48rem",
|
|
10
|
+
lg: "64rem",
|
|
11
|
+
xl: "80rem",
|
|
12
|
+
"2xl": "96rem"
|
|
13
|
+
};
|
|
14
|
+
/** Bare media queries, usable in `window.matchMedia`. Prefix with `@media ` in CSS-in-JS. */
|
|
15
|
+
var media = {
|
|
16
|
+
up: function up(name) {
|
|
17
|
+
return "(width >= ".concat(BREAKPOINTS[name], ")");
|
|
23
18
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return "".concat(isMedia ? "@media " : "", "(max-width: ").concat(this.values[breakpoint] - 1, "px)");
|
|
19
|
+
down: function down(name) {
|
|
20
|
+
return "(width < ".concat(BREAKPOINTS[name], ")");
|
|
27
21
|
},
|
|
28
|
-
between: function between(
|
|
29
|
-
|
|
30
|
-
min = _ref2[0],
|
|
31
|
-
max = _ref2[1];
|
|
32
|
-
var isMedia = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
33
|
-
var from = this.values[min];
|
|
34
|
-
var to = this.values[max] - 1;
|
|
35
|
-
return "".concat(isMedia ? "@media " : "", "(min-width: ").concat(from, "px) and (max-width: ").concat(to, "px)");
|
|
22
|
+
between: function between(from, to) {
|
|
23
|
+
return "(".concat(BREAKPOINTS[from], " <= width < ").concat(BREAKPOINTS[to], ")");
|
|
36
24
|
}
|
|
37
25
|
};
|
|
38
26
|
|
|
39
|
-
exports.
|
|
27
|
+
exports.BREAKPOINTS = BREAKPOINTS;
|
|
28
|
+
exports.media = media;
|
package/Theme/index.d.ts
CHANGED
package/Theme/index.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
var tokens = require('../Button/tokens.js');
|
|
4
4
|
var jaipur = require('./themes/jaipur.js');
|
|
5
5
|
var buenos_aires = require('./themes/buenos_aires.js');
|
|
6
|
+
var breakpoints = require('./breakpoints.js');
|
|
6
7
|
|
|
7
8
|
var THEMES = {
|
|
8
9
|
JAIPUR: Object.assign(Object.assign({}, jaipur.default), tokens.BUTTON_TOKENS),
|
|
9
10
|
BA: Object.assign(Object.assign({}, buenos_aires.default), tokens.BUTTON_TOKENS)
|
|
10
11
|
};
|
|
11
12
|
|
|
13
|
+
exports.BREAKPOINTS = breakpoints.BREAKPOINTS;
|
|
14
|
+
exports.media = breakpoints.media;
|
|
12
15
|
exports.THEMES = THEMES;
|
package/esm/Modal/index.js
CHANGED
|
@@ -41,7 +41,7 @@ var ModalRoot = function ModalRoot(_ref) {
|
|
|
41
41
|
var parentContainer = withinParent ? parentModal === null || parentModal === void 0 ? void 0 : parentModal.container : undefined;
|
|
42
42
|
var isContained = Boolean(parentContainer);
|
|
43
43
|
var isDesktop = useMediaSizes(function (bp) {
|
|
44
|
-
return bp.up("
|
|
44
|
+
return bp.up("lg");
|
|
45
45
|
});
|
|
46
46
|
var titleId = useId();
|
|
47
47
|
var _useState3 = useState(0),
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
sm:
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Breakpoints shared with the apps that use the kit.
|
|
3
|
+
* The values match the Tailwind CSS defaults on purpose; Tailwind is not a dependency.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BREAKPOINTS: {
|
|
6
|
+
readonly sm: "40rem";
|
|
7
|
+
readonly md: "48rem";
|
|
8
|
+
readonly lg: "64rem";
|
|
9
|
+
readonly xl: "80rem";
|
|
10
|
+
readonly "2xl": "96rem";
|
|
8
11
|
};
|
|
9
|
-
export type BreakpointName = keyof
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
up: (
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export type BreakpointName = keyof typeof BREAKPOINTS;
|
|
13
|
+
export type Media = {
|
|
14
|
+
/** `(width >= <name>)` */
|
|
15
|
+
up: (name: BreakpointName) => string;
|
|
16
|
+
/** `(width < <name>)` */
|
|
17
|
+
down: (name: BreakpointName) => string;
|
|
18
|
+
/** `(<from> <= width < <to>)` */
|
|
19
|
+
between: (from: BreakpointName, to: BreakpointName) => string;
|
|
15
20
|
};
|
|
16
|
-
|
|
17
|
-
declare const
|
|
18
|
-
export default Breakpoints;
|
|
21
|
+
/** Bare media queries, usable in `window.matchMedia`. Prefix with `@media ` in CSS-in-JS. */
|
|
22
|
+
export declare const media: Media;
|
package/esm/Theme/breakpoints.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Breakpoints shared with the apps that use the kit.
|
|
3
|
+
* The values match the Tailwind CSS defaults on purpose; Tailwind is not a dependency.
|
|
4
|
+
*/
|
|
5
|
+
var BREAKPOINTS = {
|
|
6
|
+
sm: "40rem",
|
|
7
|
+
md: "48rem",
|
|
8
|
+
lg: "64rem",
|
|
9
|
+
xl: "80rem",
|
|
10
|
+
"2xl": "96rem"
|
|
11
|
+
};
|
|
12
|
+
/** Bare media queries, usable in `window.matchMedia`. Prefix with `@media ` in CSS-in-JS. */
|
|
13
|
+
var media = {
|
|
14
|
+
up: function up(name) {
|
|
15
|
+
return "(width >= ".concat(BREAKPOINTS[name], ")");
|
|
15
16
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return "".concat(isMedia ? "@media " : "", "(max-width: ").concat(this.values[breakpoint] - 1, "px)");
|
|
17
|
+
down: function down(name) {
|
|
18
|
+
return "(width < ".concat(BREAKPOINTS[name], ")");
|
|
19
19
|
},
|
|
20
|
-
between: function between(
|
|
21
|
-
|
|
22
|
-
min = _ref2[0],
|
|
23
|
-
max = _ref2[1];
|
|
24
|
-
var isMedia = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
25
|
-
var from = this.values[min];
|
|
26
|
-
var to = this.values[max] - 1;
|
|
27
|
-
return "".concat(isMedia ? "@media " : "", "(min-width: ").concat(from, "px) and (max-width: ").concat(to, "px)");
|
|
20
|
+
between: function between(from, to) {
|
|
21
|
+
return "(".concat(BREAKPOINTS[from], " <= width < ").concat(BREAKPOINTS[to], ")");
|
|
28
22
|
}
|
|
29
23
|
};
|
|
30
24
|
|
|
31
|
-
export {
|
|
25
|
+
export { BREAKPOINTS, media };
|
package/esm/Theme/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type QueryInputFunction = (breakpoints:
|
|
1
|
+
import type { Media } from "../../Theme/breakpoints";
|
|
2
|
+
export type QueryInputFunction = (breakpoints: Media) => string;
|
|
3
3
|
type QueryInput = QueryInputFunction | string;
|
|
4
4
|
export declare const useMediaSizes: (queryInput: QueryInput) => boolean;
|
|
5
5
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { media } from '../../Theme/breakpoints.js';
|
|
4
4
|
|
|
5
5
|
var supportMatchMedia = typeof window !== "undefined" && typeof window.matchMedia !== "undefined";
|
|
6
6
|
var useMediaSizes = function useMediaSizes(queryInput) {
|
|
7
|
-
var query = typeof queryInput === "function" ? queryInput(
|
|
7
|
+
var query = typeof queryInput === "function" ? queryInput(media) : queryInput;
|
|
8
8
|
query = query.replace(/^@media( ?)/m, "");
|
|
9
9
|
var matchMedia = supportMatchMedia ? window.matchMedia : null;
|
|
10
10
|
var _useState = useState(function () {
|
package/esm/index.d.ts
CHANGED
|
@@ -78,7 +78,8 @@ export { TabsPanels } from "./TabsPanels";
|
|
|
78
78
|
export type { TabsPanelsProps } from "./TabsPanels/index.props";
|
|
79
79
|
export { TextArea } from "./TextArea";
|
|
80
80
|
export type { ITextAreaProps } from "./TextArea/index.props";
|
|
81
|
-
export { THEMES } from "./Theme";
|
|
81
|
+
export { THEMES, BREAKPOINTS, media } from "./Theme";
|
|
82
|
+
export type { BreakpointName, Media } from "./Theme";
|
|
82
83
|
export { TimeSelect } from "./TimeSelect";
|
|
83
84
|
export type { TimeSelectProps } from "./TimeSelect/index.props";
|
|
84
85
|
export { Tooltip } from "./Tooltip";
|
package/esm/index.js
CHANGED
|
@@ -65,6 +65,7 @@ export { Setting } from './Icons/Setting.js';
|
|
|
65
65
|
export { Shield } from './Icons/Shield.js';
|
|
66
66
|
export { Trash } from './Icons/Trash.js';
|
|
67
67
|
export { User } from './Icons/User.js';
|
|
68
|
+
export { BREAKPOINTS, media } from './Theme/breakpoints.js';
|
|
68
69
|
export { Body as ModalBody } from './Modal/components/Body/index.js';
|
|
69
70
|
export { Footer as ModalFooter } from './Modal/components/Footer/index.js';
|
|
70
71
|
export { Header as ModalHeader } from './Modal/components/Header/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type QueryInputFunction = (breakpoints:
|
|
1
|
+
import type { Media } from "../../Theme/breakpoints";
|
|
2
|
+
export type QueryInputFunction = (breakpoints: Media) => string;
|
|
3
3
|
type QueryInput = QueryInputFunction | string;
|
|
4
4
|
export declare const useMediaSizes: (queryInput: QueryInput) => boolean;
|
|
5
5
|
export {};
|
|
@@ -10,7 +10,7 @@ var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
|
|
|
10
10
|
|
|
11
11
|
var supportMatchMedia = typeof window !== "undefined" && typeof window.matchMedia !== "undefined";
|
|
12
12
|
var useMediaSizes = function useMediaSizes(queryInput) {
|
|
13
|
-
var query = typeof queryInput === "function" ? queryInput(breakpoints.
|
|
13
|
+
var query = typeof queryInput === "function" ? queryInput(breakpoints.media) : queryInput;
|
|
14
14
|
query = query.replace(/^@media( ?)/m, "");
|
|
15
15
|
var matchMedia = supportMatchMedia ? window.matchMedia : null;
|
|
16
16
|
var _useState = React.useState(function () {
|
package/index.d.ts
CHANGED
|
@@ -78,7 +78,8 @@ export { TabsPanels } from "./TabsPanels";
|
|
|
78
78
|
export type { TabsPanelsProps } from "./TabsPanels/index.props";
|
|
79
79
|
export { TextArea } from "./TextArea";
|
|
80
80
|
export type { ITextAreaProps } from "./TextArea/index.props";
|
|
81
|
-
export { THEMES } from "./Theme";
|
|
81
|
+
export { THEMES, BREAKPOINTS, media } from "./Theme";
|
|
82
|
+
export type { BreakpointName, Media } from "./Theme";
|
|
82
83
|
export { TimeSelect } from "./TimeSelect";
|
|
83
84
|
export type { TimeSelectProps } from "./TimeSelect/index.props";
|
|
84
85
|
export { Tooltip } from "./Tooltip";
|
package/index.js
CHANGED
|
@@ -49,6 +49,7 @@ var index$B = require('./hooks/useScrollLock/index.js');
|
|
|
49
49
|
require('./Icons/index.js');
|
|
50
50
|
var ArrowNext = require('./Icons/ArrowNext.js');
|
|
51
51
|
var Autocomplete = require('./Autocomplete/Autocomplete.js');
|
|
52
|
+
var breakpoints = require('./Theme/breakpoints.js');
|
|
52
53
|
var Calendar = require('./Calendar/Calendar.js');
|
|
53
54
|
var Card = require('./Card/Card.js');
|
|
54
55
|
var Cart = require('./Icons/Cart.js');
|
|
@@ -124,6 +125,8 @@ exports.useMediaSizes = index$A.useMediaSizes;
|
|
|
124
125
|
exports.useScrollLock = index$B.useScrollLock;
|
|
125
126
|
exports.ArrowNext = ArrowNext.ArrowNext;
|
|
126
127
|
exports.Autocomplete = Autocomplete.Autocomplete;
|
|
128
|
+
exports.BREAKPOINTS = breakpoints.BREAKPOINTS;
|
|
129
|
+
exports.media = breakpoints.media;
|
|
127
130
|
exports.Calendar = Calendar.Calendar;
|
|
128
131
|
exports.Card = Card.Card;
|
|
129
132
|
exports.CardContent = Card.CardContent;
|