@sentry/scraps 0.1.0
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/LICENSE.md +105 -0
- package/README.md +67 -0
- package/dist/code/inlineCode.d.ts +7 -0
- package/dist/code/inlineCode.js +38 -0
- package/dist/cssTypes.d.ts +57 -0
- package/dist/cssTypes.js +0 -0
- package/dist/hotkey/kbd.d.ts +8 -0
- package/dist/hotkey/kbd.js +31 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/layout/container.d.ts +114 -0
- package/dist/layout/container.js +161 -0
- package/dist/layout/flex.d.ts +42 -0
- package/dist/layout/flex.js +42 -0
- package/dist/layout/grid.d.ts +65 -0
- package/dist/layout/grid.js +83 -0
- package/dist/layout/index.d.ts +13 -0
- package/dist/layout/index.js +6 -0
- package/dist/layout/stack.d.ts +15 -0
- package/dist/layout/stack.js +55 -0
- package/dist/layout/styles.d.ts +118 -0
- package/dist/layout/styles.js +237 -0
- package/dist/layout/surface.d.ts +27 -0
- package/dist/layout/surface.js +28 -0
- package/dist/loader/indeterminateLoader.d.ts +5 -0
- package/dist/loader/indeterminateLoader.js +122 -0
- package/dist/loader/index.d.ts +1 -0
- package/dist/loader/index.js +1 -0
- package/dist/quote/index.d.ts +1 -0
- package/dist/quote/index.js +1 -0
- package/dist/quote/quote.d.ts +13 -0
- package/dist/quote/quote.js +73 -0
- package/dist/separator/index.d.ts +1 -0
- package/dist/separator/index.js +1 -0
- package/dist/separator/separator.d.ts +15 -0
- package/dist/separator/separator.js +29 -0
- package/dist/text/heading.d.ts +44 -0
- package/dist/text/heading.js +69 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.js +2 -0
- package/dist/text/styles.d.ts +5 -0
- package/dist/text/styles.js +18 -0
- package/dist/text/text.d.ts +152 -0
- package/dist/text/text.js +81 -0
- package/dist/theme/base.d.ts +106 -0
- package/dist/theme/base.js +7 -0
- package/dist/theme/dark.d.ts +1904 -0
- package/dist/theme/dark.js +430 -0
- package/dist/theme/index.d.ts +14 -0
- package/dist/theme/index.js +3 -0
- package/dist/theme/light.d.ts +1904 -0
- package/dist/theme/light.js +430 -0
- package/dist/theme/types.d.ts +80 -0
- package/dist/theme/types.js +0 -0
- package/dist/tokens/color.d.ts +3309 -0
- package/dist/tokens/color.js +453 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/size.d.ts +372 -0
- package/dist/tokens/size.js +75 -0
- package/dist/tokens/typography.d.ts +88 -0
- package/dist/tokens/typography.js +35 -0
- package/package.json +83 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2008-2026 Functional Software, Inc. dba Sentry
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Scraps
|
|
2
|
+
|
|
3
|
+
Scraps is the implementation of Sentry's design system. It contains the components, themes, and design tokens used to build Sentry's product interface.
|
|
4
|
+
|
|
5
|
+
The source code is open, but the system is designed for Sentry and is not intended for use in other products. This package is not a general-purpose design system.
|
|
6
|
+
|
|
7
|
+
## Development in Sentry
|
|
8
|
+
|
|
9
|
+
The package source lives in [src](./src). Component stories remain in the app.
|
|
10
|
+
|
|
11
|
+
Move components and their tests into `src` as they become isolated. The [Scraps contribution guide](../../app/components/core/overview/contributing.mdx) covers component contributions and the Figma process for changing design tokens.
|
|
12
|
+
|
|
13
|
+
Run package checks from the repository root:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pnpm --dir static/packages/scraps test
|
|
17
|
+
pnpm --dir static/packages/scraps typecheck
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
To check package imports through the Sentry app's aliases, run the app integration test:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pnpm test-ci static/app/components/core/scraps.spec.tsx
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Build and pack
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pnpm --dir static/packages/scraps pack --pack-destination .artifacts
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The `prepack` hook builds JavaScript and declarations with
|
|
33
|
+
[Rslib](./rslib.config.mjs), including from a clean checkout. Only `dist`, the
|
|
34
|
+
package manifest, README, and license ship.
|
|
35
|
+
|
|
36
|
+
The `exports` field in [package.json](./package.json) defines the published API.
|
|
37
|
+
Only the root, theme, tokens, and component barrels are public. Individual
|
|
38
|
+
module paths remain private.
|
|
39
|
+
Add an entry only when its runtime and type dependencies belong to the package
|
|
40
|
+
or are declared dependencies. App stories cover more components than this API;
|
|
41
|
+
for example, the hotkey story uses both `Hotkey` and `Kbd`, but only `Kbd` is
|
|
42
|
+
isolated. Published consumers have no fallback to app components.
|
|
43
|
+
|
|
44
|
+
## Verify the package
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pnpm --dir static/packages/scraps verify
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Verification deletes `dist` before packing to exercise `prepack`, checks the
|
|
51
|
+
tarball contents and dependencies, typechecks and imports each public export,
|
|
52
|
+
and server renders representative components in both themes.
|
|
53
|
+
|
|
54
|
+
Consumers provide Emotion's `ThemeProvider` with `lightTheme` or `darkTheme`.
|
|
55
|
+
The package does not include application providers, global CSS, or fonts.
|
|
56
|
+
|
|
57
|
+
## Prepare a release
|
|
58
|
+
|
|
59
|
+
Add a nonempty `## <version>` section to [CHANGELOG.md](./CHANGELOG.md), then
|
|
60
|
+
run the `Prepare Scraps release` GitHub workflow with that version. The initial
|
|
61
|
+
entry is `0.1.0`. Craft's `simple` policy rejects a release without a matching
|
|
62
|
+
entry.
|
|
63
|
+
|
|
64
|
+
Craft creates a `scraps/release/<version>` branch and opens a request in
|
|
65
|
+
`getsentry/publish`. The package workflow verifies that branch and uploads its
|
|
66
|
+
npm tarball. A release manager must approve the request before Craft publishes.
|
|
67
|
+
The Sentry Docker release uses the root `.craft.yml`.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Theme } from '../theme/index.js';
|
|
2
|
+
export declare const inlineCodeStyles: (theme: Theme, props?: InlineCodeProps) => import("@emotion/react").SerializedStyles;
|
|
3
|
+
interface InlineCodeProps extends React.HTMLProps<HTMLElementTagNameMap['code']> {
|
|
4
|
+
variant?: 'neutral' | 'accent';
|
|
5
|
+
}
|
|
6
|
+
export declare function InlineCode(props: InlineCodeProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css, useTheme } from "@emotion/react";
|
|
3
|
+
const inlineCodeStyles = (theme, props)=>css`
|
|
4
|
+
/**
|
|
5
|
+
* Reset any properties that might be set by the global CSS styles.
|
|
6
|
+
*/
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
border: none;
|
|
10
|
+
|
|
11
|
+
font-family: ${theme.font.family.mono};
|
|
12
|
+
/**
|
|
13
|
+
* adjust height of x character to 57% of bounding box
|
|
14
|
+
* to match Rubik's x-height (magic number)
|
|
15
|
+
*/
|
|
16
|
+
font-size-adjust: ex-height 0.57;
|
|
17
|
+
|
|
18
|
+
color: ${props?.variant === 'neutral' ? theme.tokens.content.primary : theme.tokens.content.promotion};
|
|
19
|
+
background: ${props?.variant === 'neutral' ? theme.tokens.background.transparent.neutral.muted : theme.tokens.background.transparent.promotion.muted};
|
|
20
|
+
|
|
21
|
+
padding-inline: 0.3ch;
|
|
22
|
+
margin-inline: -0.15ch;
|
|
23
|
+
border-radius: ${theme.radius['2xs']};
|
|
24
|
+
/* 3px (2xs) at 14px font-size and 8px (lg) at 24px font */
|
|
25
|
+
border-radius: clamp(0.21em, 0.28em, 0.57em);
|
|
26
|
+
|
|
27
|
+
text-box-edge: text text;
|
|
28
|
+
text-box-trim: trim-both;
|
|
29
|
+
`;
|
|
30
|
+
function InlineCode(props) {
|
|
31
|
+
const theme = useTheme();
|
|
32
|
+
const { variant: _, ...domProps } = props;
|
|
33
|
+
return /*#__PURE__*/ jsx("code", {
|
|
34
|
+
css: inlineCodeStyles(theme, props),
|
|
35
|
+
...domProps
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export { InlineCode, inlineCodeStyles };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type Globals = 'inherit' | 'initial' | 'revert' | 'revert-layer' | 'unset' | CssFunction;
|
|
2
|
+
type CssFunction = `${string}(${string})`;
|
|
3
|
+
type BaseDimension = 'auto' | '0' | 0;
|
|
4
|
+
type BaseSize = 'fit-content' | 'max-content' | 'min-content' | 'stretch' | BaseDimension;
|
|
5
|
+
type CssNumber = number | `${number}`;
|
|
6
|
+
type GridPlacement = 'auto' | number | (string & {});
|
|
7
|
+
type GridTrackSize = 'auto' | 'max-content' | 'min-content' | number | (string & {});
|
|
8
|
+
type BaselinePosition = 'baseline' | `${'first' | 'last'} baseline`;
|
|
9
|
+
type OverflowPosition = 'safe' | 'unsafe';
|
|
10
|
+
type SelfPosition = 'center' | 'start' | 'end' | 'self-start' | 'self-end' | 'flex-start' | 'flex-end';
|
|
11
|
+
type SelfAlignment = 'auto' | 'normal' | 'stretch' | 'anchor-center' | 'dialog' | BaselinePosition | SelfPosition | `${OverflowPosition} ${SelfPosition}`;
|
|
12
|
+
/**
|
|
13
|
+
* Units that make sense for either dimension.
|
|
14
|
+
*/
|
|
15
|
+
type BaseUnit = 'px' | 'em' | 'rem' | 'ex' | 'rex' | 'cap' | 'rcap' | 'ch' | 'rch' | '%';
|
|
16
|
+
type WidthUnit = BaseUnit | 'vw' | 'svw' | 'lvw' | 'dvw' | 'vmin' | 'vmax' | 'svmin' | 'svmax' | 'lvmin' | 'lvmax' | 'dvmin' | 'dvmax' | 'cqw' | 'cqi' | 'cqmin' | 'cqmax';
|
|
17
|
+
type HeightUnit = BaseUnit | 'vh' | 'svh' | 'lvh' | 'dvh' | 'vmin' | 'vmax' | 'svmin' | 'svmax' | 'lvmin' | 'lvmax' | 'dvmin' | 'dvmax' | 'lh' | 'rlh' | 'cqh' | 'cqb' | 'cqmin' | 'cqmax';
|
|
18
|
+
type BaseFlexBasis = 'none' | 'content' | 'max-content' | 'min-content' | 'fit-content' | BaseDimension;
|
|
19
|
+
type CssFlexBasis = BaseFlexBasis | `${number}${WidthUnit}` | CssFunction | Globals;
|
|
20
|
+
type Width = BaseSize | `${number}${WidthUnit}` | Globals;
|
|
21
|
+
type Height = BaseSize | `${number}${HeightUnit}` | Globals;
|
|
22
|
+
type Cursor = Globals | '-moz-grab' | '-webkit-grab' | 'alias' | 'all-scroll' | 'auto' | 'cell' | 'col-resize' | 'context-menu' | 'copy' | 'crosshair' | 'default' | 'e-resize' | 'ew-resize' | 'grab' | 'grabbing' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nesw-resize' | 'no-drop' | 'none' | 'not-allowed' | 'ns-resize' | 'nw-resize' | 'nwse-resize' | 'pointer' | 'progress' | 'row-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'vertical-text' | 'w-resize' | 'wait' | 'zoom-in' | 'zoom-out';
|
|
23
|
+
type Contain = Globals | 'content' | 'inline-size' | 'layout' | 'none' | 'paint' | 'size' | 'strict' | 'style';
|
|
24
|
+
type PointerEvents = Globals | 'all' | 'auto' | 'fill' | 'inherit' | 'none' | 'painted' | 'stroke' | 'visible' | 'visibleFill' | 'visiblePainted' | 'visibleStroke';
|
|
25
|
+
type AspectRatio = `${number}/${number}` | `${number}` | 'auto' | Globals;
|
|
26
|
+
type Position = Globals | 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky';
|
|
27
|
+
export type CSS = {
|
|
28
|
+
alignSelf: SelfAlignment | Globals;
|
|
29
|
+
aspectRatio: AspectRatio;
|
|
30
|
+
contain: Contain;
|
|
31
|
+
cursor: Cursor;
|
|
32
|
+
display: 'block' | 'inline' | 'inline-block' | 'flex' | 'inline-flex' | 'grid' | 'inline-grid' | 'contents' | 'none';
|
|
33
|
+
flex: CssFlexBasis | 'none' | 'auto' | 'initial' | number | `${number}` | `${number} ${number}` | `${number} ${CssFlexBasis}` | `${number} ${number} ${CssFlexBasis}` | Globals;
|
|
34
|
+
flexBasis: CssFlexBasis;
|
|
35
|
+
flexGrow: CssNumber | Globals;
|
|
36
|
+
flexShrink: CssNumber | Globals;
|
|
37
|
+
gridArea: GridPlacement | Globals;
|
|
38
|
+
gridAutoColumns: GridTrackSize | Globals;
|
|
39
|
+
gridAutoRows: GridTrackSize | Globals;
|
|
40
|
+
gridColumn: GridPlacement | Globals;
|
|
41
|
+
gridRow: GridPlacement | Globals;
|
|
42
|
+
gridTemplateAreas: 'none' | (string & {}) | Globals;
|
|
43
|
+
gridTemplateColumns: 'none' | 'subgrid' | 'masonry' | number | (string & {}) | Globals;
|
|
44
|
+
gridTemplateRows: 'none' | 'subgrid' | 'masonry' | number | (string & {}) | Globals;
|
|
45
|
+
height: Height;
|
|
46
|
+
inset: `${number}${HeightUnit}` | Globals | BaseDimension;
|
|
47
|
+
justifySelf: SelfAlignment | 'left' | 'right' | `${OverflowPosition} ${SelfPosition | 'left' | 'right'}` | Globals;
|
|
48
|
+
maxHeight: Height | 'none';
|
|
49
|
+
maxWidth: Width | 'none';
|
|
50
|
+
minHeight: Height;
|
|
51
|
+
minWidth: Width;
|
|
52
|
+
order: CssNumber | Globals;
|
|
53
|
+
pointerEvents: PointerEvents;
|
|
54
|
+
position: Position;
|
|
55
|
+
width: Width;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
package/dist/cssTypes.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Theme } from '../theme/index.js';
|
|
2
|
+
export declare const kbdStyles: (theme: Theme, variant?: KbdProps["variant"]) => import("@emotion/react").SerializedStyles;
|
|
3
|
+
interface KbdProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
variant?: 'embossed' | 'debossed';
|
|
6
|
+
}
|
|
7
|
+
export declare function Kbd(props: KbdProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css, useTheme } from "@emotion/react";
|
|
3
|
+
const kbdStyles = (theme, variant)=>css`
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 0 ${theme.space.xs};
|
|
6
|
+
height: 1.67em; /* 20px */
|
|
7
|
+
|
|
8
|
+
font-family: ${theme.font.family.mono};
|
|
9
|
+
font-size: ${theme.font.size.sm};
|
|
10
|
+
font-weight: ${theme.font.weight.sans.medium};
|
|
11
|
+
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
|
|
16
|
+
color: ${'debossed' === variant ? theme.tokens.content.secondary : theme.tokens.content.primary};
|
|
17
|
+
background: ${'debossed' === variant ? theme.tokens.background.secondary : theme.tokens.background.primary};
|
|
18
|
+
border: ${theme.border.md} solid ${theme.tokens.border.primary};
|
|
19
|
+
border-top: ${'debossed' === variant ? `${theme.border.xl} solid ${theme.tokens.border.primary}` : void 0};
|
|
20
|
+
border-bottom: ${'debossed' === variant ? void 0 : `${theme.border.xl} solid ${theme.tokens.border.primary}`};
|
|
21
|
+
border-radius: ${theme.radius.sm};
|
|
22
|
+
box-shadow: none;
|
|
23
|
+
`;
|
|
24
|
+
function Kbd(props) {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
return /*#__PURE__*/ jsx("kbd", {
|
|
27
|
+
css: kbdStyles(theme, props.variant),
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { Kbd, kbdStyles };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './layout/index.js';
|
|
2
|
+
export * from './text/index.js';
|
|
3
|
+
export * from './separator/index.js';
|
|
4
|
+
export * from './quote/index.js';
|
|
5
|
+
export * from './loader/index.js';
|
|
6
|
+
export { InlineCode } from './code/inlineCode.js';
|
|
7
|
+
export { Kbd } from './hotkey/kbd.js';
|
|
8
|
+
export * from './theme/index.js';
|
|
9
|
+
export * from './tokens/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./layout/index.js";
|
|
2
|
+
export * from "./text/index.js";
|
|
3
|
+
export * from "./separator/index.js";
|
|
4
|
+
export * from "./quote/index.js";
|
|
5
|
+
export * from "./loader/index.js";
|
|
6
|
+
export * from "./theme/index.js";
|
|
7
|
+
export * from "./tokens/index.js";
|
|
8
|
+
export { InlineCode } from "./code/inlineCode.js";
|
|
9
|
+
export { Kbd } from "./hotkey/kbd.js";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CSS } from '../cssTypes.js';
|
|
3
|
+
import type { BorderVariant, RadiusSize, SpaceSize, SurfaceVariant } from '../theme/index.js';
|
|
4
|
+
import { type Responsive, type Shorthand } from './styles.js';
|
|
5
|
+
type Margin = SpaceSize | 'auto' | '0';
|
|
6
|
+
interface ContainerLayoutProps {
|
|
7
|
+
background?: Responsive<Exclude<SurfaceVariant, 'overlay'>>;
|
|
8
|
+
display?: Responsive<CSS['display']>;
|
|
9
|
+
padding?: Responsive<Shorthand<SpaceSize, 4>>;
|
|
10
|
+
paddingTop?: Responsive<SpaceSize>;
|
|
11
|
+
paddingBottom?: Responsive<SpaceSize>;
|
|
12
|
+
paddingLeft?: Responsive<SpaceSize>;
|
|
13
|
+
paddingRight?: Responsive<SpaceSize>;
|
|
14
|
+
position?: Responsive<CSS['position']>;
|
|
15
|
+
inset?: Responsive<CSS['inset']>;
|
|
16
|
+
top?: Responsive<CSS['inset']>;
|
|
17
|
+
bottom?: Responsive<CSS['inset']>;
|
|
18
|
+
left?: Responsive<CSS['inset']>;
|
|
19
|
+
right?: Responsive<CSS['inset']>;
|
|
20
|
+
overflow?: Responsive<'visible' | 'hidden' | 'scroll' | 'auto'>;
|
|
21
|
+
overflowX?: Responsive<'visible' | 'hidden' | 'scroll' | 'auto'>;
|
|
22
|
+
overflowY?: Responsive<'visible' | 'hidden' | 'scroll' | 'auto'>;
|
|
23
|
+
overscrollBehavior?: Responsive<'contain' | 'auto' | 'none'>;
|
|
24
|
+
pointerEvents?: Responsive<CSS['pointerEvents']>;
|
|
25
|
+
cursor?: Responsive<CSS['cursor']>;
|
|
26
|
+
contain?: Responsive<CSS['contain']>;
|
|
27
|
+
/**
|
|
28
|
+
* Declares this element as a query container, so descendants' container
|
|
29
|
+
* responsive props (bare breakpoint keys like `{xs: …}`) resolve against its
|
|
30
|
+
* size. Maps to the CSS `container-type`.
|
|
31
|
+
*
|
|
32
|
+
* Prefer `inline-size`: it only contains the inline (width) axis, so height
|
|
33
|
+
* still flows from content. `size` additionally contains the block axis, so
|
|
34
|
+
* the element must get its height from elsewhere or its content collapses —
|
|
35
|
+
* only reach for it when you genuinely need height-based queries. `normal`
|
|
36
|
+
* (the default) means the element is not a size query container, so
|
|
37
|
+
* descendants resolve against the next container up — equivalent to omitting
|
|
38
|
+
* the prop.
|
|
39
|
+
*/
|
|
40
|
+
containerType?: 'inline-size' | 'size' | 'normal';
|
|
41
|
+
radius?: Responsive<Shorthand<RadiusSize, 4>>;
|
|
42
|
+
width?: Responsive<CSS['width']>;
|
|
43
|
+
minWidth?: Responsive<CSS['minWidth']>;
|
|
44
|
+
maxWidth?: Responsive<CSS['maxWidth']>;
|
|
45
|
+
height?: Responsive<CSS['height']>;
|
|
46
|
+
minHeight?: Responsive<CSS['minHeight']>;
|
|
47
|
+
maxHeight?: Responsive<CSS['maxHeight']>;
|
|
48
|
+
border?: Responsive<BorderVariant>;
|
|
49
|
+
borderTop?: Responsive<BorderVariant>;
|
|
50
|
+
borderBottom?: Responsive<BorderVariant>;
|
|
51
|
+
borderLeft?: Responsive<BorderVariant>;
|
|
52
|
+
borderRight?: Responsive<BorderVariant>;
|
|
53
|
+
area?: Responsive<CSS['gridArea']>;
|
|
54
|
+
row?: Responsive<CSS['gridRow']>;
|
|
55
|
+
column?: Responsive<CSS['gridColumn']>;
|
|
56
|
+
order?: Responsive<CSS['order']>;
|
|
57
|
+
flex?: Responsive<CSS['flex']>;
|
|
58
|
+
flexGrow?: Responsive<CSS['flexGrow']>;
|
|
59
|
+
flexShrink?: Responsive<CSS['flexShrink']>;
|
|
60
|
+
flexBasis?: Responsive<CSS['flexBasis']>;
|
|
61
|
+
alignSelf?: Responsive<CSS['alignSelf']>;
|
|
62
|
+
justifySelf?: Responsive<CSS['justifySelf']>;
|
|
63
|
+
visibility?: Responsive<'visible' | 'hidden' | 'collapse'>;
|
|
64
|
+
whiteSpace?: Responsive<'break-spaces' | 'normal' | 'nowrap' | 'pre' | 'pre-line' | 'pre-wrap'>;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use the `gap` prop on `Flex` or `Grid` instead.
|
|
67
|
+
*/
|
|
68
|
+
margin?: Responsive<Shorthand<Margin, 4>>;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use the `gap` prop on `Flex` or `Grid` instead.
|
|
71
|
+
*/
|
|
72
|
+
marginTop?: Responsive<Margin>;
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use the `gap` prop on `Flex` or `Grid` instead.
|
|
75
|
+
*/
|
|
76
|
+
marginBottom?: Responsive<Margin>;
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated Use the `gap` prop on `Flex` or `Grid` instead.
|
|
79
|
+
*/
|
|
80
|
+
marginLeft?: Responsive<Margin>;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use the `gap` prop on `Flex` or `Grid` instead.
|
|
83
|
+
*/
|
|
84
|
+
marginRight?: Responsive<Margin>;
|
|
85
|
+
}
|
|
86
|
+
export type ContainerElement = 'article' | 'aside' | 'blockquote' | 'div' | 'dl' | 'fieldset' | 'figure' | 'footer' | 'header' | 'label' | 'li' | 'main' | 'nav' | 'ol' | 'section' | 'span' | 'summary' | 'td' | 'th' | 'ul' | 'hr';
|
|
87
|
+
export type ContainerProps<T extends ContainerElement = 'div'> = ContainerLayoutProps & {
|
|
88
|
+
as?: T;
|
|
89
|
+
children?: React.ReactNode;
|
|
90
|
+
htmlFor?: T extends 'label' ? string : never;
|
|
91
|
+
ref?: React.Ref<HTMLElementTagNameMap[T] | null>;
|
|
92
|
+
/**
|
|
93
|
+
* Deprecated in favor of the Container component API.
|
|
94
|
+
* If you have an is an unsupported use-case, please contact design engineering for support.
|
|
95
|
+
* @deprecated
|
|
96
|
+
*/
|
|
97
|
+
style?: React.CSSProperties;
|
|
98
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElementTagNameMap[T]>, HTMLElementTagNameMap[T]>, 'style'>;
|
|
99
|
+
export type ContainerPropsWithRenderFunction<T extends ContainerElement = 'div'> = Omit<ContainerLayoutProps, 'containerType'> & {
|
|
100
|
+
children: (props: {
|
|
101
|
+
className: string;
|
|
102
|
+
}) => React.ReactNode | undefined;
|
|
103
|
+
as?: never;
|
|
104
|
+
/**
|
|
105
|
+
* Declaring a query container is not supported with the render-prop form: the
|
|
106
|
+
* styled component must own the DOM node to observe it for JS resolution,
|
|
107
|
+
* which the render prop hands to the caller. Use the standard children form.
|
|
108
|
+
*/
|
|
109
|
+
containerType?: never;
|
|
110
|
+
htmlFor?: never;
|
|
111
|
+
ref?: never;
|
|
112
|
+
} & Partial<Record<Exclude<keyof React.DetailedHTMLProps<React.HTMLAttributes<HTMLElementTagNameMap[T]>, HTMLElementTagNameMap[T]>, 'children'>, never>>;
|
|
113
|
+
export declare const Container: <T extends ContainerElement = "div">(props: ContainerProps<T> | ContainerPropsWithRenderFunction<T>) => React.ReactElement;
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
|
+
import is_prop_valid from "@emotion/is-prop-valid";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
6
|
+
import { ContainerQueryProvider, getBorder, getMargin, getRadius, getSpacing, rc } from "./styles.js";
|
|
7
|
+
const omitContainerProps = new Set([
|
|
8
|
+
'alignSelf',
|
|
9
|
+
'area',
|
|
10
|
+
'as',
|
|
11
|
+
'background',
|
|
12
|
+
'border',
|
|
13
|
+
'borderTop',
|
|
14
|
+
'borderBottom',
|
|
15
|
+
'borderLeft',
|
|
16
|
+
'borderRight',
|
|
17
|
+
'bottom',
|
|
18
|
+
'column',
|
|
19
|
+
'contain',
|
|
20
|
+
'cursor',
|
|
21
|
+
'display',
|
|
22
|
+
'flex',
|
|
23
|
+
'flexBasis',
|
|
24
|
+
'flexGrow',
|
|
25
|
+
'flexShrink',
|
|
26
|
+
'height',
|
|
27
|
+
'inset',
|
|
28
|
+
'justifySelf',
|
|
29
|
+
'left',
|
|
30
|
+
'margin',
|
|
31
|
+
'marginTop',
|
|
32
|
+
'marginBottom',
|
|
33
|
+
'marginLeft',
|
|
34
|
+
'marginRight',
|
|
35
|
+
'maxHeight',
|
|
36
|
+
'maxWidth',
|
|
37
|
+
'minHeight',
|
|
38
|
+
'minWidth',
|
|
39
|
+
'order',
|
|
40
|
+
'overflow',
|
|
41
|
+
'overflowX',
|
|
42
|
+
'overflowY',
|
|
43
|
+
'overscrollBehavior',
|
|
44
|
+
'pointerEvents',
|
|
45
|
+
'padding',
|
|
46
|
+
'paddingTop',
|
|
47
|
+
'paddingBottom',
|
|
48
|
+
'paddingLeft',
|
|
49
|
+
'paddingRight',
|
|
50
|
+
'position',
|
|
51
|
+
'radius',
|
|
52
|
+
'right',
|
|
53
|
+
'row',
|
|
54
|
+
'top',
|
|
55
|
+
'visibility',
|
|
56
|
+
'width',
|
|
57
|
+
'whiteSpace'
|
|
58
|
+
]);
|
|
59
|
+
const Container = styled((props)=>{
|
|
60
|
+
const containerRef = useRef(null);
|
|
61
|
+
const { as, containerType, ref, ...rest } = props;
|
|
62
|
+
const isContainer = !!containerType && 'normal' !== containerType;
|
|
63
|
+
const containerRefs = useMemo(()=>isContainer ? mergeRefs(ref, containerRef) : ref, [
|
|
64
|
+
isContainer,
|
|
65
|
+
ref
|
|
66
|
+
]);
|
|
67
|
+
if ('function' == typeof props.children) return props.children({
|
|
68
|
+
className: props.className ?? ''
|
|
69
|
+
});
|
|
70
|
+
const Component = as ?? 'div';
|
|
71
|
+
const node = /*#__PURE__*/ jsx(Component, {
|
|
72
|
+
...rest,
|
|
73
|
+
ref: containerRefs
|
|
74
|
+
});
|
|
75
|
+
if (isContainer) return /*#__PURE__*/ jsx(ContainerQueryProvider, {
|
|
76
|
+
elementRef: containerRef,
|
|
77
|
+
children: node
|
|
78
|
+
});
|
|
79
|
+
return node;
|
|
80
|
+
}, {
|
|
81
|
+
shouldForwardProp: (prop)=>{
|
|
82
|
+
if ('containerType' === prop) return true;
|
|
83
|
+
if (omitContainerProps.has(prop)) return false;
|
|
84
|
+
return is_prop_valid(prop);
|
|
85
|
+
}
|
|
86
|
+
})`
|
|
87
|
+
${(p)=>rc('container-type', p.containerType, p.theme)};
|
|
88
|
+
|
|
89
|
+
${(p)=>rc('display', p.display, p.theme)};
|
|
90
|
+
${(p)=>rc('position', p.position, p.theme)};
|
|
91
|
+
|
|
92
|
+
${(p)=>rc('inset', p.inset, p.theme)};
|
|
93
|
+
${(p)=>rc('top', p.top, p.theme)};
|
|
94
|
+
${(p)=>rc('bottom', p.bottom, p.theme)};
|
|
95
|
+
${(p)=>rc('left', p.left, p.theme)};
|
|
96
|
+
${(p)=>rc('right', p.right, p.theme)};
|
|
97
|
+
|
|
98
|
+
${(p)=>rc('overflow', p.overflow, p.theme)};
|
|
99
|
+
${(p)=>rc('overflow-x', p.overflowX, p.theme)};
|
|
100
|
+
${(p)=>rc('overflow-y', p.overflowY, p.theme)};
|
|
101
|
+
|
|
102
|
+
${(p)=>rc('overscroll-behavior', p.overscrollBehavior, p.theme)};
|
|
103
|
+
|
|
104
|
+
${(p)=>rc('pointer-events', p.pointerEvents, p.theme)};
|
|
105
|
+
|
|
106
|
+
${(p)=>rc('cursor', p.cursor, p.theme)};
|
|
107
|
+
${(p)=>rc('contain', p.contain, p.theme)};
|
|
108
|
+
|
|
109
|
+
${(p)=>rc('padding', p.padding, p.theme, getSpacing)};
|
|
110
|
+
${(p)=>rc('padding-top', p.paddingTop, p.theme, getSpacing)};
|
|
111
|
+
${(p)=>rc('padding-bottom', p.paddingBottom, p.theme, getSpacing)};
|
|
112
|
+
${(p)=>rc('padding-left', p.paddingLeft, p.theme, getSpacing)};
|
|
113
|
+
${(p)=>rc('padding-right', p.paddingRight, p.theme, getSpacing)};
|
|
114
|
+
|
|
115
|
+
${(p)=>rc('margin', p.margin, p.theme, getMargin)};
|
|
116
|
+
${(p)=>rc('margin-top', p.marginTop, p.theme, getMargin)};
|
|
117
|
+
${(p)=>rc('margin-bottom', p.marginBottom, p.theme, getMargin)};
|
|
118
|
+
${(p)=>rc('margin-left', p.marginLeft, p.theme, getMargin)};
|
|
119
|
+
${(p)=>rc('margin-right', p.marginRight, p.theme, getMargin)};
|
|
120
|
+
|
|
121
|
+
${(p)=>rc('background', p.background, p.theme, (v)=>v ? p.theme.tokens.background[v] : void 0)};
|
|
122
|
+
|
|
123
|
+
${(p)=>rc('border-radius', p.radius, p.theme, getRadius)};
|
|
124
|
+
|
|
125
|
+
${(p)=>rc('width', p.width, p.theme)};
|
|
126
|
+
${(p)=>rc('min-width', p.minWidth, p.theme)};
|
|
127
|
+
${(p)=>rc('max-width', p.maxWidth, p.theme)};
|
|
128
|
+
|
|
129
|
+
${(p)=>rc('height', p.height, p.theme)};
|
|
130
|
+
${(p)=>rc('min-height', p.minHeight, p.theme)};
|
|
131
|
+
${(p)=>rc('max-height', p.maxHeight, p.theme)};
|
|
132
|
+
|
|
133
|
+
${(p)=>rc('grid-area', p.area, p.theme)};
|
|
134
|
+
${(p)=>rc('grid-row', p.row, p.theme)};
|
|
135
|
+
${(p)=>rc('grid-column', p.column, p.theme)};
|
|
136
|
+
|
|
137
|
+
${(p)=>rc('order', p.order, p.theme)};
|
|
138
|
+
${(p)=>rc('flex', p.flex, p.theme)};
|
|
139
|
+
${(p)=>rc('flex-grow', p.flexGrow, p.theme)};
|
|
140
|
+
${(p)=>rc('flex-shrink', p.flexShrink, p.theme)};
|
|
141
|
+
${(p)=>rc('flex-basis', p.flexBasis, p.theme)};
|
|
142
|
+
|
|
143
|
+
${(p)=>rc('align-self', p.alignSelf, p.theme)};
|
|
144
|
+
${(p)=>rc('justify-self', p.justifySelf, p.theme)};
|
|
145
|
+
|
|
146
|
+
${(p)=>rc('border', p.border, p.theme, getBorder)};
|
|
147
|
+
${(p)=>rc('border-top', p.borderTop, p.theme, getBorder)};
|
|
148
|
+
${(p)=>rc('border-bottom', p.borderBottom, p.theme, getBorder)};
|
|
149
|
+
${(p)=>rc('border-left', p.borderLeft, p.theme, getBorder)};
|
|
150
|
+
${(p)=>rc('border-right', p.borderRight, p.theme, getBorder)};
|
|
151
|
+
|
|
152
|
+
${(p)=>rc('visibility', p.visibility, p.theme)};
|
|
153
|
+
${(p)=>rc('white-space', p.whiteSpace, p.theme)};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* This cast is required because styled-components does not preserve the generic signature of the wrapped component.
|
|
157
|
+
* By default, the generic type parameter <T> is lost, so we use 'as unknown as' to restore the correct typing.
|
|
158
|
+
* https://github.com/styled-components/styled-components/issues/1803
|
|
159
|
+
*/
|
|
160
|
+
`;
|
|
161
|
+
export { Container };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CSS } from '../cssTypes.js';
|
|
2
|
+
import type { SpaceSize } from '../theme/index.js';
|
|
3
|
+
import { type ContainerElement, type ContainerProps, type ContainerPropsWithRenderFunction } from './container.js';
|
|
4
|
+
import { type FlexJustify, type Responsive } from './styles.js';
|
|
5
|
+
interface FlexLayoutProps {
|
|
6
|
+
/**
|
|
7
|
+
* Aligns flex items along the cross axis of the current line of flex items.
|
|
8
|
+
* Uses CSS align-items property.
|
|
9
|
+
*/
|
|
10
|
+
align?: Responsive<'start' | 'end' | 'center' | 'baseline' | 'stretch'>;
|
|
11
|
+
/**
|
|
12
|
+
* Specifies the direction of the flex items.
|
|
13
|
+
*/
|
|
14
|
+
direction?: Responsive<'row' | 'row-reverse' | 'column' | 'column-reverse'>;
|
|
15
|
+
/**
|
|
16
|
+
* Specifies the display type of the flex container.
|
|
17
|
+
*/
|
|
18
|
+
display?: Responsive<'flex' | 'inline-flex' | 'none'>;
|
|
19
|
+
/**
|
|
20
|
+
* Shorthand for the flex property.
|
|
21
|
+
*/
|
|
22
|
+
flex?: Responsive<CSS['flex']>;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies the spacing between flex items.
|
|
25
|
+
*/
|
|
26
|
+
gap?: Responsive<SpaceSize | `${SpaceSize} ${SpaceSize}`>;
|
|
27
|
+
/**
|
|
28
|
+
* Aligns flex items along the block axis of the current line of flex items.
|
|
29
|
+
* Uses CSS justify-content property.
|
|
30
|
+
*/
|
|
31
|
+
justify?: Responsive<FlexJustify>;
|
|
32
|
+
/**
|
|
33
|
+
* Specifies the wrapping behavior of the flex items.
|
|
34
|
+
*/
|
|
35
|
+
wrap?: Responsive<'nowrap' | 'wrap' | 'wrap-reverse'>;
|
|
36
|
+
}
|
|
37
|
+
export interface FlexProps<T extends ContainerElement = 'div'> extends Omit<ContainerProps<T>, 'display'>, FlexLayoutProps {
|
|
38
|
+
}
|
|
39
|
+
export interface FlexPropsWithRenderFunction<T extends ContainerElement = 'div'> extends Omit<ContainerPropsWithRenderFunction<T>, 'display'>, FlexLayoutProps {
|
|
40
|
+
}
|
|
41
|
+
export declare const Flex: <T extends ContainerElement = "div">(props: FlexProps<T> | FlexPropsWithRenderFunction<T>) => React.ReactElement;
|
|
42
|
+
export {};
|