@automattic/vip-design-system 2.15.9 → 2.17.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/.github/workflows/npm-prepare-release.yml +2 -2
- package/.github/workflows/npm-publish.yml +10 -2
- package/AGENTS.md +102 -0
- package/CLAUDE.md +1 -0
- package/build/system/NewForm/FormSelect.d.ts +1 -0
- package/build/system/NewForm/FormSelect.js +8 -3
- package/build/system/NewForm/FormSelectArrow.d.ts +1 -0
- package/build/system/NewForm/FormSelectArrow.js +17 -14
- package/build/system/NewTooltip/NewTooltip.d.ts +16 -0
- package/build/system/NewTooltip/NewTooltip.js +44 -0
- package/build/system/NewTooltip/NewTooltip.stories.d.ts +17 -0
- package/build/system/NewTooltip/NewTooltip.stories.js +230 -0
- package/build/system/NewTooltip/NewTooltip.test.d.ts +1 -0
- package/build/system/NewTooltip/NewTooltip.test.js +254 -0
- package/build/system/NewTooltip/NewTooltipArrow.d.ts +8 -0
- package/build/system/NewTooltip/NewTooltipArrow.js +18 -0
- package/build/system/NewTooltip/NewTooltipContent.d.ts +8 -0
- package/build/system/NewTooltip/NewTooltipContent.js +24 -0
- package/build/system/NewTooltip/index.d.ts +8 -0
- package/build/system/NewTooltip/index.js +9 -0
- package/build/system/NewTooltip/styles.d.ts +4 -0
- package/build/system/NewTooltip/styles.js +17 -0
- package/build/system/Pagination/Pagination.d.ts +22 -0
- package/build/system/Pagination/Pagination.js +228 -0
- package/build/system/Pagination/Pagination.stories.d.ts +18 -0
- package/build/system/Pagination/Pagination.stories.js +183 -0
- package/build/system/Pagination/Pagination.test.d.ts +2 -0
- package/build/system/Pagination/Pagination.test.js +363 -0
- package/build/system/Pagination/index.d.ts +2 -0
- package/build/system/Pagination/index.js +1 -0
- package/build/system/Pagination/styles.d.ts +9 -0
- package/build/system/Pagination/styles.js +96 -0
- package/build/system/Tooltip/Tooltip.d.ts +6 -0
- package/build/system/Tooltip/Tooltip.js +7 -0
- package/build/system/Tooltip/Tooltip.stories.js +1 -1
- package/build/system/index.d.ts +3 -1
- package/build/system/index.js +4 -0
- package/package.json +5 -1
- package/src/system/NewForm/FormSelect.tsx +8 -2
- package/src/system/NewForm/FormSelectArrow.tsx +24 -19
- package/src/system/NewTooltip/NewTooltip.stories.tsx +160 -0
- package/src/system/NewTooltip/NewTooltip.test.tsx +167 -0
- package/src/system/NewTooltip/NewTooltip.tsx +61 -0
- package/src/system/NewTooltip/NewTooltipArrow.tsx +19 -0
- package/src/system/NewTooltip/NewTooltipContent.tsx +27 -0
- package/src/system/NewTooltip/index.ts +11 -0
- package/src/system/NewTooltip/styles.ts +20 -0
- package/src/system/Pagination/Pagination.stories.tsx +167 -0
- package/src/system/Pagination/Pagination.test.tsx +264 -0
- package/src/system/Pagination/Pagination.tsx +266 -0
- package/src/system/Pagination/index.ts +2 -0
- package/src/system/Pagination/styles.ts +106 -0
- package/src/system/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/system/Tooltip/Tooltip.tsx +6 -0
- package/src/system/index.js +4 -0
|
@@ -20,10 +20,10 @@ jobs:
|
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
steps:
|
|
22
22
|
- name: Check out the source code
|
|
23
|
-
uses: actions/checkout@
|
|
23
|
+
uses: actions/checkout@v6
|
|
24
24
|
|
|
25
25
|
- name: Run npm-prepare-release
|
|
26
|
-
uses: Automattic/vip-actions/npm-prepare-release@v0.
|
|
26
|
+
uses: Automattic/vip-actions/npm-prepare-release@v0.7.3
|
|
27
27
|
with:
|
|
28
28
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
29
29
|
npm-version-type: ${{ inputs.npm-version-type }}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
---
|
|
1
2
|
name: Publish to npm (if applicable)
|
|
2
3
|
|
|
3
4
|
on:
|
|
@@ -8,9 +9,16 @@ jobs:
|
|
|
8
9
|
publish:
|
|
9
10
|
name: Publish to npm
|
|
10
11
|
runs-on: ubuntu-latest
|
|
12
|
+
environment: npm-publish
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
contents: write
|
|
16
|
+
pull-requests: write
|
|
11
17
|
if: contains( github.event.pull_request.labels.*.name, '[ Type ] NPM version update' ) && startsWith( github.head_ref, 'release/') && github.event.pull_request.merged == true
|
|
18
|
+
|
|
12
19
|
steps:
|
|
13
|
-
- uses: Automattic/vip-actions/npm-publish@v0.
|
|
20
|
+
- uses: Automattic/vip-actions/npm-publish@v0.7.3
|
|
14
21
|
with:
|
|
22
|
+
USE_TRUSTED_PUBLISHING: 'true'
|
|
23
|
+
PROVENANCE: 'false'
|
|
15
24
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
16
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Agents
|
|
2
|
+
|
|
3
|
+
Instructions for AI agents working on this codebase.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is `@automattic/vip-design-system`, a React component library and design token system published to npm. It provides 40+ reusable UI components for VIP projects.
|
|
8
|
+
|
|
9
|
+
## Tech Stack
|
|
10
|
+
|
|
11
|
+
- **React 18** with **TypeScript 5.2**
|
|
12
|
+
- **Theme UI 0.16** for styling (CSS-in-JS via Emotion)
|
|
13
|
+
- **Radix UI** for accessible primitive components (accordion, checkbox, dialog, dropdown, switch, tabs, tooltip)
|
|
14
|
+
- **Babel 7** for compilation (output to `build/`)
|
|
15
|
+
- **Jest 29** + **@testing-library/react** + **jest-axe** for testing
|
|
16
|
+
- **Storybook 7.6** for component documentation
|
|
17
|
+
- **ESLint 8** with `@automattic/eslint-plugin-wpvip` + **Prettier** (`wp-prettier`)
|
|
18
|
+
|
|
19
|
+
## Code Structure
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
src/system/ # All components, theme, and utilities
|
|
23
|
+
src/system/<Component>/ # Individual component directories
|
|
24
|
+
ComponentName.tsx # Component implementation
|
|
25
|
+
ComponentName.test.tsx # Unit tests
|
|
26
|
+
ComponentName.stories.tsx # Storybook documentation
|
|
27
|
+
index.ts # Re-exports (optional)
|
|
28
|
+
src/system/theme/ # Theme configuration and generated tokens
|
|
29
|
+
src/system/utils/ # Shared utility functions
|
|
30
|
+
src/system/index.js # Package entry point (re-exports all components)
|
|
31
|
+
tokens/ # Design token source files (from Figma Studio)
|
|
32
|
+
.storybook/ # Storybook configuration and decorators
|
|
33
|
+
docs/ # Detailed documentation (architecture, contributing, testing, releasing)
|
|
34
|
+
build/ # Compiled output (generated, do not edit)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
| Command | Purpose |
|
|
40
|
+
| ---------------------- | -------------------------------------- |
|
|
41
|
+
| `npm run test` | Run Jest unit tests |
|
|
42
|
+
| `npm run lint` | Run ESLint |
|
|
43
|
+
| `npm run lint:fix` | Auto-fix ESLint issues |
|
|
44
|
+
| `npm run format:check` | Check Prettier formatting |
|
|
45
|
+
| `npm run format` | Auto-format with Prettier |
|
|
46
|
+
| `npm run check-types` | TypeScript type checking |
|
|
47
|
+
| `npm run build` | Full production build |
|
|
48
|
+
| `npm run dev` | Start Storybook dev server (port 6006) |
|
|
49
|
+
|
|
50
|
+
## Component Conventions
|
|
51
|
+
|
|
52
|
+
### Creating Components
|
|
53
|
+
|
|
54
|
+
- Place new components in `src/system/<ComponentName>/`.
|
|
55
|
+
- Each component needs at minimum: `ComponentName.tsx`, `ComponentName.test.tsx`, and `ComponentName.stories.tsx`.
|
|
56
|
+
- Export the component from `src/system/index.js`.
|
|
57
|
+
|
|
58
|
+
### Coding Standards
|
|
59
|
+
|
|
60
|
+
- Follow the WPVIP ESLint configuration defined in `.eslintrc.js`.
|
|
61
|
+
- Use Prettier formatting (`wp-prettier`). Run `npm run format` before committing.
|
|
62
|
+
- Use TypeScript for all new code. Define prop interfaces with explicit types.
|
|
63
|
+
- Use `forwardRef` when wrapping HTML elements or Theme UI components.
|
|
64
|
+
|
|
65
|
+
### Styling
|
|
66
|
+
|
|
67
|
+
- Use Theme UI's `sx` prop for styling. Do not use inline styles or CSS modules.
|
|
68
|
+
- Reference theme tokens for colors, spacing, and typography (do not hardcode values).
|
|
69
|
+
- Support both light and dark themes through the token system.
|
|
70
|
+
|
|
71
|
+
### Accessibility
|
|
72
|
+
|
|
73
|
+
- Accessibility is a priority. Use Radix UI primitives when building interactive components (dialogs, dropdowns, tooltips, etc.).
|
|
74
|
+
- Include `jest-axe` tests (`toHaveNoViolations`) in component test files.
|
|
75
|
+
- Ensure proper ARIA attributes, keyboard navigation, and screen reader support.
|
|
76
|
+
|
|
77
|
+
### Testing
|
|
78
|
+
|
|
79
|
+
- Write tests using `@testing-library/react`. Test user-visible behavior, not implementation details.
|
|
80
|
+
- Include accessibility tests with `jest-axe`.
|
|
81
|
+
- Place test files next to the component: `ComponentName.test.tsx`.
|
|
82
|
+
- All tests must pass before submitting a PR: `npm run test`.
|
|
83
|
+
|
|
84
|
+
### Storybook Stories
|
|
85
|
+
|
|
86
|
+
- Write stories using the CSF3 format (Component Story Format).
|
|
87
|
+
- Include multiple variants and states of the component.
|
|
88
|
+
- Place stories next to the component: `ComponentName.stories.tsx`.
|
|
89
|
+
|
|
90
|
+
## Theme and Design Tokens
|
|
91
|
+
|
|
92
|
+
- Tokens are managed via Figma Studio and stored in `tokens/`.
|
|
93
|
+
- Run `npm run theme-update` to regenerate theme files from tokens.
|
|
94
|
+
- Do not manually edit files in `src/system/theme/generated/` — they are overwritten by the theme update script.
|
|
95
|
+
- Light theme: `wpvip-product-core`. Dark theme: `wpvip-product-dark`.
|
|
96
|
+
|
|
97
|
+
## Git Workflow
|
|
98
|
+
|
|
99
|
+
- Main branch: `trunk`.
|
|
100
|
+
- Versioning follows semver (`major.minor.patch`).
|
|
101
|
+
- Releases are published to npm via GitHub Actions (preferred) or locally.
|
|
102
|
+
- PRs require passing CI checks: lint, format, type checking, and tests.
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -17,6 +17,7 @@ interface FormSelectProps {
|
|
|
17
17
|
options: Option[];
|
|
18
18
|
required?: boolean;
|
|
19
19
|
label?: string;
|
|
20
|
+
separator?: boolean;
|
|
20
21
|
getOptionLabel?: (option: Option) => string;
|
|
21
22
|
getOptionValue?: (option: Option) => string | number;
|
|
22
23
|
onChange?: (option: Option | undefined, event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["disabled", "isInline", "placeholder", "forLabel", "options", "required", "label", "getOptionLabel", "getOptionValue", "onChange", "hasError", "errorMessage", "wrapperSx"],
|
|
1
|
+
var _excluded = ["disabled", "isInline", "placeholder", "forLabel", "options", "required", "label", "getOptionLabel", "getOptionValue", "onChange", "hasError", "errorMessage", "wrapperSx", "separator"],
|
|
2
2
|
_excluded2 = ["options"];
|
|
3
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
4
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -63,6 +63,8 @@ var FormSelect = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
|
|
|
63
63
|
hasError = _ref2.hasError,
|
|
64
64
|
errorMessage = _ref2.errorMessage,
|
|
65
65
|
wrapperSx = _ref2.wrapperSx,
|
|
66
|
+
_ref2$separator = _ref2.separator,
|
|
67
|
+
separator = _ref2$separator === void 0 ? true : _ref2$separator,
|
|
66
68
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
67
69
|
if (isDev && options.length > MAX_SUGGESTED_OPTIONS) {
|
|
68
70
|
// eslint-disable-next-line no-console
|
|
@@ -112,7 +114,9 @@ var FormSelect = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
|
|
|
112
114
|
ref: forwardRef,
|
|
113
115
|
sx: _extends({
|
|
114
116
|
cursor: disabled ? 'not-allowed' : 'pointer'
|
|
115
|
-
}, defaultStyles
|
|
117
|
+
}, defaultStyles, !separator && {
|
|
118
|
+
paddingRight: 6
|
|
119
|
+
}),
|
|
116
120
|
required: required,
|
|
117
121
|
disabled: disabled,
|
|
118
122
|
"aria-required": required,
|
|
@@ -127,7 +131,8 @@ var FormSelect = /*#__PURE__*/React.forwardRef(function (_ref2, forwardRef) {
|
|
|
127
131
|
return groupOptions ? renderGroup(optionLabel(option), groupOptions) : renderOption(optionLabel(option), optionValue(option));
|
|
128
132
|
})]
|
|
129
133
|
})), _jsx(FormSelectArrow, {
|
|
130
|
-
iconSize: ICON_SIZE
|
|
134
|
+
iconSize: ICON_SIZE,
|
|
135
|
+
separator: separator
|
|
131
136
|
})]
|
|
132
137
|
}), hasError && errorMessage && _jsx(Validation, {
|
|
133
138
|
isValid: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["iconSize"];
|
|
1
|
+
var _excluded = ["iconSize", "separator"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
4
|
/** @jsxImportSource theme-ui */
|
|
@@ -13,23 +13,26 @@ import { MdExpandMore } from 'react-icons/md';
|
|
|
13
13
|
*/
|
|
14
14
|
import { baseControlBorderStyle as borderStyle } from '../Form/Input.styles';
|
|
15
15
|
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
16
|
-
var arrowStyles = {
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
paddingLeft: 2,
|
|
19
|
-
borderLeftWidth: borderStyle.borderWidth,
|
|
20
|
-
borderLeftStyle: borderStyle.borderStyle,
|
|
21
|
-
borderLeftColor: borderStyle.borderColor,
|
|
22
|
-
right: 3,
|
|
23
|
-
top: '7px',
|
|
24
|
-
pointerEvents: 'none',
|
|
25
|
-
svg: {
|
|
26
|
-
fill: borderStyle.borderColor
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
16
|
export var FormSelectArrow = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef) {
|
|
30
17
|
var _ref$iconSize = _ref.iconSize,
|
|
31
18
|
iconSize = _ref$iconSize === void 0 ? 24 : _ref$iconSize,
|
|
19
|
+
_ref$separator = _ref.separator,
|
|
20
|
+
separator = _ref$separator === void 0 ? true : _ref$separator,
|
|
32
21
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
|
+
var arrowStyles = _extends({
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
right: 3,
|
|
25
|
+
top: '7px',
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
svg: {
|
|
28
|
+
fill: borderStyle.borderColor
|
|
29
|
+
}
|
|
30
|
+
}, separator && {
|
|
31
|
+
paddingLeft: 2,
|
|
32
|
+
borderLeftWidth: borderStyle.borderWidth,
|
|
33
|
+
borderLeftStyle: borderStyle.borderStyle,
|
|
34
|
+
borderLeftColor: borderStyle.borderColor
|
|
35
|
+
});
|
|
33
36
|
return _jsx("div", {
|
|
34
37
|
ref: forwardRef,
|
|
35
38
|
children: _jsx(MdExpandMore, _extends({
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { ThemeUIStyleObject } from 'theme-ui';
|
|
4
|
+
export interface NewTooltipProps {
|
|
5
|
+
content: ReactNode;
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
8
|
+
arrow?: boolean;
|
|
9
|
+
sideOffset?: number;
|
|
10
|
+
sx?: ThemeUIStyleObject;
|
|
11
|
+
className?: string;
|
|
12
|
+
open?: boolean;
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
delayDuration?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const NewTooltip: React.FC<NewTooltipProps>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { NewTooltipArrow } from './NewTooltipArrow';
|
|
6
|
+
import { NewTooltipContent } from './NewTooltipContent';
|
|
7
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
9
|
+
export var NewTooltip = function NewTooltip(_ref) {
|
|
10
|
+
var content = _ref.content,
|
|
11
|
+
children = _ref.children,
|
|
12
|
+
_ref$position = _ref.position,
|
|
13
|
+
position = _ref$position === void 0 ? 'top' : _ref$position,
|
|
14
|
+
_ref$arrow = _ref.arrow,
|
|
15
|
+
arrow = _ref$arrow === void 0 ? false : _ref$arrow,
|
|
16
|
+
sideOffset = _ref.sideOffset,
|
|
17
|
+
sx = _ref.sx,
|
|
18
|
+
className = _ref.className,
|
|
19
|
+
open = _ref.open,
|
|
20
|
+
onOpenChange = _ref.onOpenChange,
|
|
21
|
+
_ref$delayDuration = _ref.delayDuration,
|
|
22
|
+
delayDuration = _ref$delayDuration === void 0 ? 300 : _ref$delayDuration;
|
|
23
|
+
var defaultOffset = arrow ? 8 : 4;
|
|
24
|
+
var resolvedOffset = sideOffset != null ? sideOffset : defaultOffset;
|
|
25
|
+
return _jsx(TooltipPrimitive.Provider, {
|
|
26
|
+
children: _jsxs(TooltipPrimitive.Root, {
|
|
27
|
+
open: open,
|
|
28
|
+
onOpenChange: onOpenChange,
|
|
29
|
+
delayDuration: delayDuration,
|
|
30
|
+
children: [_jsx(TooltipPrimitive.Trigger, {
|
|
31
|
+
asChild: true,
|
|
32
|
+
children: children
|
|
33
|
+
}), _jsx(TooltipPrimitive.Portal, {
|
|
34
|
+
children: _jsxs(NewTooltipContent, {
|
|
35
|
+
side: position,
|
|
36
|
+
sideOffset: resolvedOffset,
|
|
37
|
+
sx: sx,
|
|
38
|
+
className: className,
|
|
39
|
+
children: [content, arrow && _jsx(NewTooltipArrow, {})]
|
|
40
|
+
})
|
|
41
|
+
})]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").FC<import("./NewTooltip").NewTooltipProps>;
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {
|
|
7
|
+
description: {
|
|
8
|
+
component: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
14
|
+
export declare const Basic: () => import("react").JSX.Element;
|
|
15
|
+
export declare const WithArrow: () => import("react").JSX.Element;
|
|
16
|
+
export declare const RichContent: () => import("react").JSX.Element;
|
|
17
|
+
export declare const AllPositions: () => import("react").JSX.Element;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { NewTooltip, Button, Heading, Text, Grid } from '..';
|
|
5
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
7
|
+
import { Fragment as _Fragment } from "theme-ui/jsx-runtime";
|
|
8
|
+
export default {
|
|
9
|
+
title: 'NewTooltip',
|
|
10
|
+
component: NewTooltip,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component: "\nA Radix-based tooltip component that supports rich content (ReactNode), including HTML elements\nlike `<strong>` and `<br />`. Built on `@radix-ui/react-tooltip` for full accessibility support.\n\n## Component Properties\n"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export var Basic = function Basic() {
|
|
20
|
+
return _jsxs(_Fragment, {
|
|
21
|
+
children: [_jsx(Heading, {
|
|
22
|
+
variant: "h2",
|
|
23
|
+
children: "Basic Usage"
|
|
24
|
+
}), _jsx(Text, {
|
|
25
|
+
sx: {
|
|
26
|
+
mb: 4
|
|
27
|
+
},
|
|
28
|
+
children: "A simple tooltip with plain text content on each position."
|
|
29
|
+
}), _jsxs(Grid, {
|
|
30
|
+
columns: ['auto auto'],
|
|
31
|
+
gap: '100px 160px',
|
|
32
|
+
sx: {
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
pt: '50px'
|
|
35
|
+
},
|
|
36
|
+
children: [_jsx(NewTooltip, {
|
|
37
|
+
content: "At the top",
|
|
38
|
+
position: "top",
|
|
39
|
+
children: _jsx(Button, {
|
|
40
|
+
children: "Top"
|
|
41
|
+
})
|
|
42
|
+
}), _jsx(NewTooltip, {
|
|
43
|
+
content: "At the bottom",
|
|
44
|
+
position: "bottom",
|
|
45
|
+
children: _jsx(Button, {
|
|
46
|
+
children: "Bottom"
|
|
47
|
+
})
|
|
48
|
+
}), _jsx(NewTooltip, {
|
|
49
|
+
content: "On the left",
|
|
50
|
+
position: "left",
|
|
51
|
+
children: _jsx(Button, {
|
|
52
|
+
children: "Left"
|
|
53
|
+
})
|
|
54
|
+
}), _jsx(NewTooltip, {
|
|
55
|
+
content: "On the right",
|
|
56
|
+
position: "right",
|
|
57
|
+
children: _jsx(Button, {
|
|
58
|
+
children: "Right"
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
export var WithArrow = function WithArrow() {
|
|
65
|
+
return _jsxs(_Fragment, {
|
|
66
|
+
children: [_jsx(Heading, {
|
|
67
|
+
variant: "h2",
|
|
68
|
+
children: "With Arrow"
|
|
69
|
+
}), _jsx(Text, {
|
|
70
|
+
sx: {
|
|
71
|
+
mb: 4
|
|
72
|
+
},
|
|
73
|
+
children: "Enable the arrow indicator pointing to the trigger element."
|
|
74
|
+
}), _jsxs(Grid, {
|
|
75
|
+
columns: ['auto auto'],
|
|
76
|
+
gap: '100px 160px',
|
|
77
|
+
sx: {
|
|
78
|
+
justifyContent: 'center',
|
|
79
|
+
pt: '50px'
|
|
80
|
+
},
|
|
81
|
+
children: [_jsx(NewTooltip, {
|
|
82
|
+
content: "At the top with arrow",
|
|
83
|
+
position: "top",
|
|
84
|
+
arrow: true,
|
|
85
|
+
children: _jsx(Button, {
|
|
86
|
+
children: "Top"
|
|
87
|
+
})
|
|
88
|
+
}), _jsx(NewTooltip, {
|
|
89
|
+
content: "At the bottom with arrow",
|
|
90
|
+
position: "bottom",
|
|
91
|
+
arrow: true,
|
|
92
|
+
children: _jsx(Button, {
|
|
93
|
+
children: "Bottom"
|
|
94
|
+
})
|
|
95
|
+
}), _jsx(NewTooltip, {
|
|
96
|
+
content: "On the left with arrow",
|
|
97
|
+
position: "left",
|
|
98
|
+
arrow: true,
|
|
99
|
+
children: _jsx(Button, {
|
|
100
|
+
children: "Left"
|
|
101
|
+
})
|
|
102
|
+
}), _jsx(NewTooltip, {
|
|
103
|
+
content: "On the right with arrow",
|
|
104
|
+
position: "right",
|
|
105
|
+
arrow: true,
|
|
106
|
+
children: _jsx(Button, {
|
|
107
|
+
children: "Right"
|
|
108
|
+
})
|
|
109
|
+
})]
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
export var RichContent = function RichContent() {
|
|
114
|
+
return _jsxs(_Fragment, {
|
|
115
|
+
children: [_jsx(Heading, {
|
|
116
|
+
variant: "h2",
|
|
117
|
+
children: "Rich Content"
|
|
118
|
+
}), _jsxs(Text, {
|
|
119
|
+
sx: {
|
|
120
|
+
mb: 4
|
|
121
|
+
},
|
|
122
|
+
children: ["NewTooltip supports ReactNode content, including HTML elements like", ' ', _jsx("code", {
|
|
123
|
+
children: "<strong>"
|
|
124
|
+
}), " and ", _jsx("code", {
|
|
125
|
+
children: "<br />"
|
|
126
|
+
}), "."]
|
|
127
|
+
}), _jsxs(Grid, {
|
|
128
|
+
columns: ['auto auto'],
|
|
129
|
+
gap: '100px 160px',
|
|
130
|
+
sx: {
|
|
131
|
+
justifyContent: 'center',
|
|
132
|
+
pt: '50px'
|
|
133
|
+
},
|
|
134
|
+
children: [_jsx(NewTooltip, {
|
|
135
|
+
content: _jsxs(_Fragment, {
|
|
136
|
+
children: ["Press ", _jsx("strong", {
|
|
137
|
+
children: "Enter"
|
|
138
|
+
}), _jsx("br", {}), "to confirm"]
|
|
139
|
+
}),
|
|
140
|
+
arrow: true,
|
|
141
|
+
children: _jsx(Button, {
|
|
142
|
+
children: "With bold and line break"
|
|
143
|
+
})
|
|
144
|
+
}), _jsx(NewTooltip, {
|
|
145
|
+
content: _jsxs(_Fragment, {
|
|
146
|
+
children: [_jsx("strong", {
|
|
147
|
+
children: "Tip:"
|
|
148
|
+
}), " Use keyboard shortcuts for faster navigation"]
|
|
149
|
+
}),
|
|
150
|
+
arrow: true,
|
|
151
|
+
children: _jsx(Button, {
|
|
152
|
+
children: "With bold label"
|
|
153
|
+
})
|
|
154
|
+
})]
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
export var AllPositions = function AllPositions() {
|
|
159
|
+
return _jsxs(_Fragment, {
|
|
160
|
+
children: [_jsx(Heading, {
|
|
161
|
+
variant: "h2",
|
|
162
|
+
children: "All Positions"
|
|
163
|
+
}), _jsx(Text, {
|
|
164
|
+
sx: {
|
|
165
|
+
mb: 4
|
|
166
|
+
},
|
|
167
|
+
children: "All four positions with and without arrows."
|
|
168
|
+
}), _jsxs(Grid, {
|
|
169
|
+
columns: ['auto auto'],
|
|
170
|
+
gap: '100px 160px',
|
|
171
|
+
sx: {
|
|
172
|
+
justifyContent: 'center',
|
|
173
|
+
pt: '50px'
|
|
174
|
+
},
|
|
175
|
+
children: [_jsx(NewTooltip, {
|
|
176
|
+
content: "At the top",
|
|
177
|
+
position: "top",
|
|
178
|
+
children: _jsx(Button, {
|
|
179
|
+
children: "Top"
|
|
180
|
+
})
|
|
181
|
+
}), _jsx(NewTooltip, {
|
|
182
|
+
content: "At the top with arrow",
|
|
183
|
+
position: "top",
|
|
184
|
+
arrow: true,
|
|
185
|
+
children: _jsx(Button, {
|
|
186
|
+
children: "Top with Arrow"
|
|
187
|
+
})
|
|
188
|
+
}), _jsx(NewTooltip, {
|
|
189
|
+
content: "At the bottom",
|
|
190
|
+
position: "bottom",
|
|
191
|
+
children: _jsx(Button, {
|
|
192
|
+
children: "Bottom"
|
|
193
|
+
})
|
|
194
|
+
}), _jsx(NewTooltip, {
|
|
195
|
+
content: "At the bottom with arrow",
|
|
196
|
+
position: "bottom",
|
|
197
|
+
arrow: true,
|
|
198
|
+
children: _jsx(Button, {
|
|
199
|
+
children: "Bottom with Arrow"
|
|
200
|
+
})
|
|
201
|
+
}), _jsx(NewTooltip, {
|
|
202
|
+
content: "On the left",
|
|
203
|
+
position: "left",
|
|
204
|
+
children: _jsx(Button, {
|
|
205
|
+
children: "Left"
|
|
206
|
+
})
|
|
207
|
+
}), _jsx(NewTooltip, {
|
|
208
|
+
content: "On the left with arrow",
|
|
209
|
+
position: "left",
|
|
210
|
+
arrow: true,
|
|
211
|
+
children: _jsx(Button, {
|
|
212
|
+
children: "Left with Arrow"
|
|
213
|
+
})
|
|
214
|
+
}), _jsx(NewTooltip, {
|
|
215
|
+
content: "On the right",
|
|
216
|
+
position: "right",
|
|
217
|
+
children: _jsx(Button, {
|
|
218
|
+
children: "Right"
|
|
219
|
+
})
|
|
220
|
+
}), _jsx(NewTooltip, {
|
|
221
|
+
content: "On the right with arrow",
|
|
222
|
+
position: "right",
|
|
223
|
+
arrow: true,
|
|
224
|
+
children: _jsx(Button, {
|
|
225
|
+
children: "Right with Arrow"
|
|
226
|
+
})
|
|
227
|
+
})]
|
|
228
|
+
})]
|
|
229
|
+
});
|
|
230
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|