@vectara/vectara-ui 12.0.2 → 12.1.1
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/README.md +34 -0
- package/lib/components/drawer/Drawer.js +1 -1
- package/lib/components/drawer/_index.scss +4 -0
- package/lib/components/modal/Modal.d.ts +2 -1
- package/lib/components/modal/Modal.js +3 -3
- package/lib/components/modal/_index.scss +16 -13
- package/lib/styles/index.css +30 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,40 @@ If you are using Sass and need Vectara UI's Sass variables, you can use this imp
|
|
|
28
28
|
@import "@vectara/vectara-ui/lib/sassUtils/index";
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## Software design principles
|
|
32
|
+
|
|
33
|
+
We use these principles to guide how we design components, utilities, and other code in VUI.
|
|
34
|
+
|
|
35
|
+
### Features must have clear use cases
|
|
36
|
+
|
|
37
|
+
- Adding code is easy. Removing code is hard. Try not to add code.
|
|
38
|
+
- Only add code if we'll use it.
|
|
39
|
+
- If we'll use the code, demonstrate how with an example in the docs.
|
|
40
|
+
|
|
41
|
+
### Module surface area should be as small as possible
|
|
42
|
+
|
|
43
|
+
- Nobody enjoys tracking dependencies.
|
|
44
|
+
- Modules with many exports make it hard to know which exports matter.
|
|
45
|
+
- Keep modules simple. Export only what the consumer will need.
|
|
46
|
+
|
|
47
|
+
### Props should be opinionated
|
|
48
|
+
|
|
49
|
+
- Nobody enjoys CSS. The primary interface of VUI is React and TS, not CSS.
|
|
50
|
+
- Design props as abstractions over the CSS. Optimize for common use cases.
|
|
51
|
+
- Expect the consuming developer to think about the CSS as a last resort.
|
|
52
|
+
|
|
53
|
+
### Components should be composable
|
|
54
|
+
|
|
55
|
+
- Treat components like Legos.
|
|
56
|
+
- Only add a feature to a component if it can't be done by putting components together.
|
|
57
|
+
- If you're writing a lot of custom code in an example, consider moving it to a component.
|
|
58
|
+
|
|
59
|
+
### Optimize for greppability
|
|
60
|
+
|
|
61
|
+
- JS refers to CSS via strings. Our tools don't tell us when those references break.
|
|
62
|
+
- Grep is the best way to find relevant CSS class names.
|
|
63
|
+
- Write CSS class names out fully. Avoid Sass concatenation outside of loops.
|
|
64
|
+
|
|
31
65
|
## Publishing
|
|
32
66
|
|
|
33
67
|
Publishing a new version of the package consists of three steps:
|
|
@@ -49,5 +49,5 @@ export const VuiDrawer = (_a) => {
|
|
|
49
49
|
returnFocus: false,
|
|
50
50
|
// Enable focus on contents when it's open,
|
|
51
51
|
// but enable manual focus return to work when it's closed.
|
|
52
|
-
autoFocus: isOpen }, { children: _jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiDrawerHeader" }, { children: _jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [icon && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "l" }, { children: icon })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx("div", Object.assign({ className: "vuiDrawerHeader__title" }, { children: _jsx(DrawerTitle, { children: title }) })) }))] })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Close
|
|
52
|
+
autoFocus: isOpen }, { children: _jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiDrawerHeader" }, { children: _jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [icon && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "l" }, { children: icon })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx("div", Object.assign({ className: "vuiDrawerHeader__title" }, { children: _jsx(DrawerTitle, { children: title }) })) }))] })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Close", "data-testid": "drawerCloseButton", onClick: onCloseDelayed, color: "neutral", icon: _jsx(VuiIcon, Object.assign({ size: "m", color: "neutral" }, { children: _jsx(BiX, {}) })) }) }))] })) })), _jsx("div", Object.assign({ className: "vuiDrawerContent" }, { children: _jsx("div", Object.assign({ className: "vuiDrawerContent__inner" }, { children: children })) }))] })) })) })) }));
|
|
53
53
|
};
|
|
@@ -25,6 +25,10 @@ $drawerWidth: 680px;
|
|
|
25
25
|
border-left: 1px solid var(--vui-color-border-medium);
|
|
26
26
|
z-index: $drawerZIndex;
|
|
27
27
|
animation: drawerIn $transitionSpeed cubic-bezier(0, 1, 0, 1);
|
|
28
|
+
|
|
29
|
+
@media screen and (max-width: $drawerWidth + $sizeM) {
|
|
30
|
+
max-width: calc(100% - $sizeM);
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
.vuiDrawerHeader {
|
|
@@ -9,6 +9,7 @@ type Props = {
|
|
|
9
9
|
onClose?: () => void;
|
|
10
10
|
color?: (typeof COLOR)[number];
|
|
11
11
|
key?: string;
|
|
12
|
+
size?: "s" | "m" | "l";
|
|
12
13
|
};
|
|
13
|
-
export declare const VuiModal: ({ className, color, title, icon, children, isOpen, onClose, key, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const VuiModal: ({ className, color, title, icon, children, isOpen, onClose, key, size, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -23,7 +23,7 @@ import { VuiScreenBlock } from "../screenBlock/ScreenBlock";
|
|
|
23
23
|
import { useVuiContext } from "../context/Context";
|
|
24
24
|
const COLOR = ["primary", "danger"];
|
|
25
25
|
export const VuiModal = (_a) => {
|
|
26
|
-
var { className, color = "primary", title, icon, children, isOpen, onClose, key } = _a, rest = __rest(_a, ["className", "color", "title", "icon", "children", "isOpen", "onClose", "key"]);
|
|
26
|
+
var { className, color = "primary", title, icon, children, isOpen, onClose, key, size = "s" } = _a, rest = __rest(_a, ["className", "color", "title", "icon", "children", "isOpen", "onClose", "key", "size"]);
|
|
27
27
|
const { DrawerTitle } = useVuiContext();
|
|
28
28
|
const returnFocusElRef = useRef(null);
|
|
29
29
|
// Return focus on unmount.
|
|
@@ -43,11 +43,11 @@ export const VuiModal = (_a) => {
|
|
|
43
43
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
44
44
|
}, 0);
|
|
45
45
|
};
|
|
46
|
-
const classes = classNames("vuiModal", `vuiModal--${color}`, className);
|
|
46
|
+
const classes = classNames("vuiModal", `vuiModal--${color}`, `vuiModal--${size}`, className);
|
|
47
47
|
return (_jsx(VuiPortal, { children: isOpen && (_jsx(VuiScreenBlock, { children: _jsx(FocusOn, Object.assign({ onEscapeKey: onCloseDelayed, onClickOutside: onCloseDelayed,
|
|
48
48
|
// Enable manual focus return to work.
|
|
49
49
|
returnFocus: false,
|
|
50
50
|
// Enable focus on contents when it's open,
|
|
51
51
|
// but enable manual focus return to work when it's closed.
|
|
52
|
-
autoFocus: isOpen }, { children: _jsx("div", Object.assign({ className: "vuiModalContainer" }, { children: _jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiModalHeader" }, { children: _jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [icon && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "l" }, { children: icon })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx("div", Object.assign({ className: "vuiModalHeader__title" }, { children: _jsx(DrawerTitle, { children: title }) })) }))] })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Close
|
|
52
|
+
autoFocus: isOpen }, { children: _jsx("div", Object.assign({ className: "vuiModalContainer" }, { children: _jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiModalHeader" }, { children: _jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [icon && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "l" }, { children: icon })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx("div", Object.assign({ className: "vuiModalHeader__title" }, { children: _jsx(DrawerTitle, { children: title }) })) }))] })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Close", onClick: onCloseDelayed, color: "neutral", icon: _jsx(VuiIcon, Object.assign({ size: "m", color: "neutral" }, { children: _jsx(BiX, {}) })) }) }))] })) })), _jsx("div", Object.assign({ className: "vuiModalContent" }, { children: _jsx("div", Object.assign({ className: "vuiModalContent__inner" }, { children: children })) }))] })) })) })) }, key)) }));
|
|
53
53
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
@use "sass:map";
|
|
2
2
|
|
|
3
|
-
$modalWidth: 500px;
|
|
4
|
-
|
|
5
3
|
@keyframes modalIn {
|
|
6
4
|
0% {
|
|
7
5
|
transform: translateY(12px);
|
|
@@ -31,24 +29,29 @@ $modalWidth: 500px;
|
|
|
31
29
|
display: flex;
|
|
32
30
|
flex-direction: column;
|
|
33
31
|
width: 100%;
|
|
34
|
-
max-
|
|
35
|
-
max-height: calc(100vh - $sizeXl);
|
|
32
|
+
max-height: calc(100% - $sizeM * 2);
|
|
36
33
|
background-color: var(--vui-color-empty-shade);
|
|
37
34
|
border-radius: $sizeXxs;
|
|
38
35
|
z-index: $modalZIndex;
|
|
39
36
|
pointer-events: all;
|
|
40
37
|
box-shadow: rgba(57, 57, 75, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
|
|
38
|
+
transition: height $transitionSpeed, max-width $transitionSpeed, max-height $transitionSpeed;
|
|
39
|
+
}
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
$size: (
|
|
42
|
+
s: 500px,
|
|
43
|
+
m: 900px,
|
|
44
|
+
l: 1300px
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
@each $sizeName, $sizeValue in $size {
|
|
48
|
+
.vuiModal--#{$sizeName} {
|
|
49
|
+
max-width: $sizeValue;
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
@media screen and (max-width: ($sizeValue + $sizeXl * 2)) {
|
|
52
|
+
& {
|
|
53
|
+
max-width: calc(100% - $sizeM * 2);
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
}
|
package/lib/styles/index.css
CHANGED
|
@@ -2283,6 +2283,11 @@ h2.react-datepicker__current-month {
|
|
|
2283
2283
|
z-index: 11;
|
|
2284
2284
|
animation: drawerIn 0.2s cubic-bezier(0, 1, 0, 1);
|
|
2285
2285
|
}
|
|
2286
|
+
@media screen and (max-width: 696px) {
|
|
2287
|
+
.vuiDrawer {
|
|
2288
|
+
max-width: calc(100% - 16px);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2286
2291
|
|
|
2287
2292
|
.vuiDrawerHeader {
|
|
2288
2293
|
padding: 12px 24px;
|
|
@@ -3751,23 +3756,39 @@ h2.react-datepicker__current-month {
|
|
|
3751
3756
|
display: flex;
|
|
3752
3757
|
flex-direction: column;
|
|
3753
3758
|
width: 100%;
|
|
3754
|
-
max-
|
|
3755
|
-
max-height: calc(100vh - 32px);
|
|
3759
|
+
max-height: calc(100% - 32px);
|
|
3756
3760
|
background-color: var(--vui-color-empty-shade);
|
|
3757
3761
|
border-radius: 4px;
|
|
3758
3762
|
z-index: 12;
|
|
3759
3763
|
pointer-events: all;
|
|
3760
3764
|
box-shadow: rgba(57, 57, 75, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
|
|
3765
|
+
transition: height 0.2s, max-width 0.2s, max-height 0.2s;
|
|
3761
3766
|
}
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3767
|
+
|
|
3768
|
+
.vuiModal--s {
|
|
3769
|
+
max-width: 500px;
|
|
3770
|
+
}
|
|
3771
|
+
@media screen and (max-width: 564px) {
|
|
3772
|
+
.vuiModal--s {
|
|
3773
|
+
max-width: calc(100% - 32px);
|
|
3765
3774
|
}
|
|
3766
3775
|
}
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3776
|
+
|
|
3777
|
+
.vuiModal--m {
|
|
3778
|
+
max-width: 900px;
|
|
3779
|
+
}
|
|
3780
|
+
@media screen and (max-width: 964px) {
|
|
3781
|
+
.vuiModal--m {
|
|
3782
|
+
max-width: calc(100% - 32px);
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
.vuiModal--l {
|
|
3787
|
+
max-width: 1300px;
|
|
3788
|
+
}
|
|
3789
|
+
@media screen and (max-width: 1364px) {
|
|
3790
|
+
.vuiModal--l {
|
|
3791
|
+
max-width: calc(100% - 32px);
|
|
3771
3792
|
}
|
|
3772
3793
|
}
|
|
3773
3794
|
|