react-miui 0.35.0 → 0.36.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/CHANGELOG.md +4 -0
- package/dist/components/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.js +13 -3
- package/dist/components/layout/header/HeaderIconAction.js.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.styled.js +11 -17
- package/dist/components/layout/header/HeaderIconAction.styled.js.map +1 -1
- package/dist/components/layout/list/Item.d.ts.map +1 -1
- package/dist/components/layout/list/Item.js +17 -7
- package/dist/components/layout/list/Item.js.map +1 -1
- package/dist/components/layout/list/Item.styled.d.ts.map +1 -1
- package/dist/components/layout/list/Item.styled.js +2 -1
- package/dist/components/layout/list/Item.styled.js.map +1 -1
- package/dist/components/ui/button/Button.d.ts +94 -1
- package/dist/components/ui/button/Button.d.ts.map +1 -1
- package/dist/components/ui/button/Button.js +59 -2
- package/dist/components/ui/button/Button.js.map +1 -1
- package/dist/components/ui/button/Button.styled.d.ts +2 -2
- package/dist/components/ui/button/Button.styled.d.ts.map +1 -1
- package/dist/components/ui/button/Button.styled.js +4 -3
- package/dist/components/ui/button/Button.styled.js.map +1 -1
- package/dist/components/ui/directionPad/Button.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Button.js +7 -2
- package/dist/components/ui/directionPad/Button.js.map +1 -1
- package/dist/components/ui/directionPad/Button.styled.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Button.styled.js +2 -1
- package/dist/components/ui/directionPad/Button.styled.js.map +1 -1
- package/dist/components/ui/directionPad/Middle.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Middle.js +7 -1
- package/dist/components/ui/directionPad/Middle.js.map +1 -1
- package/dist/components/ui/directionPad/Middle.styled.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Middle.styled.js +2 -1
- package/dist/components/ui/directionPad/Middle.styled.js.map +1 -1
- package/dist/components/ui/modal/ModalButtons.d.ts +179 -1
- package/dist/components/ui/modal/ModalButtons.d.ts.map +1 -1
- package/dist/components/ui/modal/ModalButtons.js +63 -2
- package/dist/components/ui/modal/ModalButtons.js.map +1 -1
- package/dist/components/ui/modal/ModalButtons.styled.d.ts +90 -91
- package/dist/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
- package/dist/components/ui/modal/ModalButtons.styled.js +5 -7
- package/dist/components/ui/modal/ModalButtons.styled.js.map +1 -1
- package/dist/components/ui/pop/Pop.styled.d.ts.map +1 -1
- package/dist/components/ui/pop/Pop.styled.js +15 -17
- package/dist/components/ui/pop/Pop.styled.js.map +1 -1
- package/dist/components/ui/pop/PopOption.d.ts.map +1 -1
- package/dist/components/ui/pop/PopOption.js +7 -2
- package/dist/components/ui/pop/PopOption.js.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.d.ts +94 -1
- package/dist/components/ui/toolButton/ToolButton.d.ts.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.js +59 -2
- package/dist/components/ui/toolButton/ToolButton.js.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.styled.d.ts +2 -2
- package/dist/components/ui/toolButton/ToolButton.styled.d.ts.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.styled.js +20 -25
- package/dist/components/ui/toolButton/ToolButton.styled.js.map +1 -1
- package/dist/utils/useRipple.d.ts +15 -0
- package/dist/utils/useRipple.d.ts.map +1 -0
- package/dist/utils/useRipple.js +120 -0
- package/dist/utils/useRipple.js.map +1 -0
- package/dist/utils/useRipple.styled.d.ts +28 -0
- package/dist/utils/useRipple.styled.d.ts.map +1 -0
- package/dist/utils/useRipple.styled.js +36 -0
- package/dist/utils/useRipple.styled.js.map +1 -0
- package/docs/classes/index.Pop.html +7 -7
- package/docs/documents/Test.html +2 -2
- package/docs/enums/index.ICON.html +2 -2
- package/docs/functions/index.Action.html +3 -3
- package/docs/functions/index.Button.html +3 -9
- package/docs/functions/index.Card.html +2 -2
- package/docs/functions/index.Checkbox.html +3 -3
- package/docs/functions/index.Choice.html +2 -2
- package/docs/functions/index.ColorPicker.html +3 -3
- package/docs/functions/index.CoveringLoader.html +3 -3
- package/docs/functions/index.DirectionPad.html +2 -2
- package/docs/functions/index.Drawer.html +2 -2
- package/docs/functions/index.EqualActions.html +2 -2
- package/docs/functions/index.FullLoader.html +3 -3
- package/docs/functions/index.Gap.html +2 -2
- package/docs/functions/index.HandleEsc.html +3 -3
- package/docs/functions/index.Header.html +3 -3
- package/docs/functions/index.HeaderIconAction.html +3 -3
- package/docs/functions/index.Icon-1.html +2 -2
- package/docs/functions/index.If.html +3 -3
- package/docs/functions/index.Input.html +1 -1
- package/docs/functions/index.KeyValue.html +2 -2
- package/docs/functions/index.Label.html +2 -2
- package/docs/functions/index.Line.html +3 -3
- package/docs/functions/index.List.html +2 -2
- package/docs/functions/index.Loader.html +3 -3
- package/docs/functions/index.Loading.html +3 -3
- package/docs/functions/index.Message.html +3 -3
- package/docs/functions/index.Modal.html +2 -2
- package/docs/functions/index.ModalButtons.html +3 -3
- package/docs/functions/index.PopLoader.html +3 -3
- package/docs/functions/index.PopOption.html +2 -2
- package/docs/functions/index.Progress.html +2 -2
- package/docs/functions/index.SearchContainer.html +2 -2
- package/docs/functions/index.Section.html +4 -4
- package/docs/functions/index.Select.html +2 -2
- package/docs/functions/index.Selector.html +2 -2
- package/docs/functions/index.Spacer.html +2 -2
- package/docs/functions/index.Stats.html +2 -2
- package/docs/functions/index.StickyHeader.html +4 -4
- package/docs/functions/index.Table.html +2 -2
- package/docs/functions/index.TextArea.html +2 -2
- package/docs/functions/index.TimePicker.html +2 -2
- package/docs/functions/index.ToasterProvider.html +3 -3
- package/docs/functions/index.Toggle.html +3 -3
- package/docs/functions/index.ToolButton.html +3 -9
- package/docs/functions/index.Tooltip.html +3 -3
- package/docs/functions/index.TooltipProvider.html +2 -2
- package/docs/functions/index.borderPxToRem.html +1 -1
- package/docs/functions/index.createTheme.html +1 -1
- package/docs/functions/index.css.html +1 -1
- package/docs/functions/index.dimensionsPxToRem.html +1 -1
- package/docs/functions/index.fontPxToRem.html +1 -1
- package/docs/functions/index.getCssText.html +1 -1
- package/docs/functions/index.globalCss.html +2 -2
- package/docs/functions/index.injectGlobalStyles.html +1 -1
- package/docs/functions/index.keyframes.html +1 -1
- package/docs/functions/index.pxToRem.html +1 -1
- package/docs/functions/index.styled.html +1 -1
- package/docs/functions/index.toast.html +2 -2
- package/docs/functions/index.useToaster.html +1 -1
- package/docs/index.html +2 -2
- package/docs/interfaces/index.IconProps.html +2 -2
- package/docs/interfaces/index.InputCustomProps.html +3 -3
- package/docs/interfaces/index.LoaderProps.html +6 -6
- package/docs/interfaces/index.StickyHeaderProps.html +4 -4
- package/docs/interfaces/index.ToasterProviderProps.html +3 -3
- package/docs/interfaces/index.TooltipProps.html +14 -14
- package/docs/interfaces/index.TooltipProviderProps.html +5 -5
- package/docs/modules/index.html +1 -1
- package/docs/modules.html +1 -1
- package/docs/types/index.ActionProps.html +1 -1
- package/docs/types/index.CardProps.html +1 -1
- package/docs/types/index.CheckboxProps.html +2 -2
- package/docs/types/index.ChoiceProps.html +1 -1
- package/docs/types/index.ColorPickerProps.html +1 -1
- package/docs/types/index.DirectionPadProps.html +1 -1
- package/docs/types/index.DrawerFrom.html +1 -1
- package/docs/types/index.DrawerProps.html +2 -2
- package/docs/types/index.EqualActionsProps.html +1 -1
- package/docs/types/index.HeaderProps.html +1 -1
- package/docs/types/index.InputProps.html +1 -1
- package/docs/types/index.KeyValueProps.html +1 -1
- package/docs/types/index.LabelProps.html +1 -1
- package/docs/types/index.OverwriteProps.html +1 -1
- package/docs/types/index.ProgressProps.html +2 -2
- package/docs/types/index.SelectProps.html +1 -1
- package/docs/types/index.SelectorProps.html +1 -1
- package/docs/types/index.Stat.html +1 -1
- package/docs/types/index.StatsProps.html +1 -1
- package/docs/types/index.TextAreaProps.html +1 -1
- package/docs/types/index.ThemeCSS.html +1 -1
- package/docs/types/index.TimePickerProps.html +1 -1
- package/docs/types/index.ToggleProps.html +2 -2
- package/docs/variables/index.ActionBadgeSelector.html +1 -1
- package/docs/variables/index.ActionCircleSelector.html +1 -1
- package/docs/variables/index.CheckboxCheckmarkWrapperSelector.html +1 -1
- package/docs/variables/index.CheckboxTextLabelSelector.html +1 -1
- package/docs/variables/index.ChoiceItemSelector.html +1 -1
- package/docs/variables/index.ColorPickerColorDisplaySelector.html +1 -1
- package/docs/variables/index.DirectionPadButtonDotSelector.html +1 -1
- package/docs/variables/index.DirectionPadButtonSelector.html +1 -1
- package/docs/variables/index.DirectionPadLineSelector.html +1 -1
- package/docs/variables/index.DirectionPadMiddleSelector.html +1 -1
- package/docs/variables/index.DrawerContentSelector.html +1 -1
- package/docs/variables/index.HeaderAfterSelector.html +1 -1
- package/docs/variables/index.HeaderBeforeSelector.html +1 -1
- package/docs/variables/index.HeaderContentsSelector.html +1 -1
- package/docs/variables/index.HeaderIconActionIconSelector.html +1 -1
- package/docs/variables/index.InputContainerSelector.html +1 -1
- package/docs/variables/index.InputInputSelector.html +1 -1
- package/docs/variables/index.InputLabelSelector.html +1 -1
- package/docs/variables/index.InputPrefixSelector.html +1 -1
- package/docs/variables/index.InputSuffixSelector.html +1 -1
- package/docs/variables/index.KeyValueIconSelector.html +1 -1
- package/docs/variables/index.KeyValueItemSelector.html +1 -1
- package/docs/variables/index.KeyValueKeySelector.html +1 -1
- package/docs/variables/index.KeyValuePairSelector.html +1 -1
- package/docs/variables/index.KeyValueValueSelector.html +1 -1
- package/docs/variables/index.LabelTextSelector.html +1 -1
- package/docs/variables/index.ListItemInnerContainerClassNameSelector.html +1 -1
- package/docs/variables/index.ModalContainerSelector.html +1 -1
- package/docs/variables/index.ModalRemovePaddingSelector.html +1 -1
- package/docs/variables/index.ModalTitleSelector.html +1 -1
- package/docs/variables/index.PopListSelector.html +1 -1
- package/docs/variables/index.PopOptionButtonSelector.html +1 -1
- package/docs/variables/index.PopOptionIconSelector.html +1 -1
- package/docs/variables/index.PopOverlaySelector.html +1 -1
- package/docs/variables/index.ProgressBackgroundSelector.html +1 -1
- package/docs/variables/index.ProgressValueSelector.html +1 -1
- package/docs/variables/index.SelectorItemSelector.html +1 -1
- package/docs/variables/index.StatsItemSelector.html +1 -1
- package/docs/variables/index.StatsLabelSelector.html +1 -1
- package/docs/variables/index.StatsSeparatorSelector.html +1 -1
- package/docs/variables/index.StatsValueSelector.html +1 -1
- package/docs/variables/index.TextAreaLabelSelector.html +1 -1
- package/docs/variables/index.TextAreaTextAreaSelector.html +1 -1
- package/docs/variables/index.TextAreaWrapperSelector.html +1 -1
- package/docs/variables/index.ToggleStyledToggleSelector.html +1 -1
- package/docs/variables/index.TooltipContentSelector.html +1 -1
- package/docs/variables/index.config.html +1 -1
- package/docs/variables/index.cssReset.html +2 -2
- package/docs/variables/index.darkTheme.html +1 -1
- package/docs/variables/index.miuiScrollbars.html +1 -1
- package/docs/variables/index.theme.html +1 -1
- package/esm/components/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.js +13 -3
- package/esm/components/layout/header/HeaderIconAction.js.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.styled.js +11 -17
- package/esm/components/layout/header/HeaderIconAction.styled.js.map +1 -1
- package/esm/components/layout/list/Item.d.ts.map +1 -1
- package/esm/components/layout/list/Item.js +18 -8
- package/esm/components/layout/list/Item.js.map +1 -1
- package/esm/components/layout/list/Item.styled.d.ts.map +1 -1
- package/esm/components/layout/list/Item.styled.js +2 -1
- package/esm/components/layout/list/Item.styled.js.map +1 -1
- package/esm/components/ui/button/Button.d.ts +94 -1
- package/esm/components/ui/button/Button.d.ts.map +1 -1
- package/esm/components/ui/button/Button.js +15 -1
- package/esm/components/ui/button/Button.js.map +1 -1
- package/esm/components/ui/button/Button.styled.d.ts +2 -2
- package/esm/components/ui/button/Button.styled.d.ts.map +1 -1
- package/esm/components/ui/button/Button.styled.js +3 -2
- package/esm/components/ui/button/Button.styled.js.map +1 -1
- package/esm/components/ui/directionPad/Button.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Button.js +7 -2
- package/esm/components/ui/directionPad/Button.js.map +1 -1
- package/esm/components/ui/directionPad/Button.styled.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Button.styled.js +2 -1
- package/esm/components/ui/directionPad/Button.styled.js.map +1 -1
- package/esm/components/ui/directionPad/Middle.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Middle.js +7 -1
- package/esm/components/ui/directionPad/Middle.js.map +1 -1
- package/esm/components/ui/directionPad/Middle.styled.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Middle.styled.js +2 -1
- package/esm/components/ui/directionPad/Middle.styled.js.map +1 -1
- package/esm/components/ui/modal/ModalButtons.d.ts +179 -1
- package/esm/components/ui/modal/ModalButtons.d.ts.map +1 -1
- package/esm/components/ui/modal/ModalButtons.js +19 -1
- package/esm/components/ui/modal/ModalButtons.js.map +1 -1
- package/esm/components/ui/modal/ModalButtons.styled.d.ts +90 -91
- package/esm/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
- package/esm/components/ui/modal/ModalButtons.styled.js +3 -6
- package/esm/components/ui/modal/ModalButtons.styled.js.map +1 -1
- package/esm/components/ui/pop/Pop.styled.d.ts.map +1 -1
- package/esm/components/ui/pop/Pop.styled.js +15 -17
- package/esm/components/ui/pop/Pop.styled.js.map +1 -1
- package/esm/components/ui/pop/PopOption.d.ts.map +1 -1
- package/esm/components/ui/pop/PopOption.js +7 -2
- package/esm/components/ui/pop/PopOption.js.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.d.ts +94 -1
- package/esm/components/ui/toolButton/ToolButton.d.ts.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.js +15 -1
- package/esm/components/ui/toolButton/ToolButton.js.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.styled.d.ts +2 -2
- package/esm/components/ui/toolButton/ToolButton.styled.d.ts.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.styled.js +19 -24
- package/esm/components/ui/toolButton/ToolButton.styled.js.map +1 -1
- package/esm/utils/useRipple.d.ts +15 -0
- package/esm/utils/useRipple.d.ts.map +1 -0
- package/esm/utils/useRipple.js +84 -0
- package/esm/utils/useRipple.js.map +1 -0
- package/esm/utils/useRipple.styled.d.ts +28 -0
- package/esm/utils/useRipple.styled.d.ts.map +1 -0
- package/esm/utils/useRipple.styled.js +33 -0
- package/esm/utils/useRipple.styled.js.map +1 -0
- package/package.json +1 -1
- package/src/components/layout/header/HeaderIconAction.styled.ts +11 -18
- package/src/components/layout/header/HeaderIconAction.tsx +32 -5
- package/src/components/layout/list/Item.styled.ts +2 -1
- package/src/components/layout/list/Item.tsx +38 -5
- package/src/components/ui/button/Button.styled.ts +3 -2
- package/src/components/ui/button/Button.tsx +33 -1
- package/src/components/ui/directionPad/Button.styled.ts +2 -1
- package/src/components/ui/directionPad/Button.tsx +13 -1
- package/src/components/ui/directionPad/Middle.styled.ts +2 -1
- package/src/components/ui/directionPad/Middle.tsx +13 -1
- package/src/components/ui/modal/ModalButtons.styled.ts +4 -7
- package/src/components/ui/modal/ModalButtons.tsx +38 -1
- package/src/components/ui/pop/Pop.styled.ts +15 -18
- package/src/components/ui/pop/PopOption.tsx +15 -1
- package/src/components/ui/toolButton/ToolButton.styled.ts +20 -26
- package/src/components/ui/toolButton/ToolButton.tsx +33 -0
- package/src/utils/useRipple.styled.ts +56 -0
- package/src/utils/useRipple.tsx +139 -0
- package/src/components/ui/toolButton/ToolButton.ts +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useCallback, useRef, useState } from "react";
|
|
2
|
+
const HALF = 2;
|
|
3
|
+
const RIPPLE_SPEED_PX_PER_MS = 1.5;
|
|
4
|
+
const RIPPLE_MIN_DURATION_MS = 250;
|
|
5
|
+
const prefersReducedMotion = () => {
|
|
6
|
+
if (typeof window === "undefined") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
10
|
+
};
|
|
11
|
+
const isDisabled = (el) => {
|
|
12
|
+
if ("disabled" in el && el.disabled) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return el.getAttribute("aria-disabled") === "true";
|
|
16
|
+
};
|
|
17
|
+
const isRippleDisabledByCssVar = (el) => {
|
|
18
|
+
if (typeof window === "undefined") {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return window.getComputedStyle(el).getPropertyValue("--miui-ripple").trim() === "0";
|
|
22
|
+
};
|
|
23
|
+
const useRipple = (args) => {
|
|
24
|
+
const { ref, onPointerDown, onKeyDown, fromCenter = false } = args;
|
|
25
|
+
const [ripples, setRipples] = useState([]);
|
|
26
|
+
const idCounter = useRef(0);
|
|
27
|
+
const addRippleAt = useCallback((clientX, clientY) => {
|
|
28
|
+
const el = ref.current;
|
|
29
|
+
if (!el || isDisabled(el) || prefersReducedMotion() || isRippleDisabledByCssVar(el)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const rect = el.getBoundingClientRect();
|
|
33
|
+
const x = clientX - rect.left;
|
|
34
|
+
const y = clientY - rect.top;
|
|
35
|
+
const maxX = Math.max(x, rect.width - x);
|
|
36
|
+
const maxY = Math.max(y, rect.height - y);
|
|
37
|
+
const size = Math.hypot(maxX, maxY) * HALF;
|
|
38
|
+
const duration = Math.max(RIPPLE_MIN_DURATION_MS, size / RIPPLE_SPEED_PX_PER_MS);
|
|
39
|
+
idCounter.current += 1;
|
|
40
|
+
const id = idCounter.current;
|
|
41
|
+
setRipples((arr) => [...arr, { id, x, y, size, duration }]);
|
|
42
|
+
}, [ref]);
|
|
43
|
+
const handlePointerDown = useCallback((evt) => {
|
|
44
|
+
if (fromCenter) {
|
|
45
|
+
const el = ref.current;
|
|
46
|
+
if (el) {
|
|
47
|
+
const rect = el.getBoundingClientRect();
|
|
48
|
+
addRippleAt(rect.left + (rect.width / HALF), rect.top + (rect.height / HALF));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
addRippleAt(evt.clientX, evt.clientY);
|
|
53
|
+
}
|
|
54
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(evt);
|
|
55
|
+
}, [addRippleAt, onPointerDown, fromCenter, ref]);
|
|
56
|
+
const handleKeyDown = useCallback((evt) => {
|
|
57
|
+
if (!evt.repeat && (evt.key === "Enter" || evt.key === " ")) {
|
|
58
|
+
const el = ref.current;
|
|
59
|
+
if (el) {
|
|
60
|
+
const rect = el.getBoundingClientRect();
|
|
61
|
+
addRippleAt(rect.left + (rect.width / HALF), rect.top + (rect.height / HALF));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(evt);
|
|
65
|
+
}, [addRippleAt, ref, onKeyDown]);
|
|
66
|
+
const handleAnimationEnd = useCallback((evt) => {
|
|
67
|
+
const id = Number(evt.currentTarget.dataset.rippleId);
|
|
68
|
+
setRipples((arr) => arr.filter((r) => r.id !== id));
|
|
69
|
+
}, []);
|
|
70
|
+
const elements = ripples.map((r) => (React.createElement("span", { key: r.id, "data-miui-ripple": true, "data-ripple-id": r.id, "aria-hidden": true, style: {
|
|
71
|
+
left: `${String(r.x - (r.size / HALF))}px`,
|
|
72
|
+
top: `${String(r.y - (r.size / HALF))}px`,
|
|
73
|
+
width: `${String(r.size)}px`,
|
|
74
|
+
height: `${String(r.size)}px`,
|
|
75
|
+
animationDuration: `${String(r.duration)}ms`,
|
|
76
|
+
}, onAnimationEnd: handleAnimationEnd })));
|
|
77
|
+
return {
|
|
78
|
+
onPointerDown: handlePointerDown,
|
|
79
|
+
onKeyDown: handleKeyDown,
|
|
80
|
+
ripples: elements,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export { useRipple };
|
|
84
|
+
//# sourceMappingURL=useRipple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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const rippleHostStyles: {
|
|
2
|
+
position: string;
|
|
3
|
+
overflow: string;
|
|
4
|
+
WebkitTapHighlightColor: string;
|
|
5
|
+
transition: string;
|
|
6
|
+
"&:where(a, button):hover:not(:disabled):not([aria-disabled='true'])": {
|
|
7
|
+
boxShadow: string;
|
|
8
|
+
};
|
|
9
|
+
"&:where(a, button):active:not(:disabled):not([aria-disabled='true'])": {
|
|
10
|
+
boxShadow: string;
|
|
11
|
+
};
|
|
12
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
13
|
+
transition: string;
|
|
14
|
+
};
|
|
15
|
+
"& > span[data-miui-ripple]": {
|
|
16
|
+
position: string;
|
|
17
|
+
pointerEvents: string;
|
|
18
|
+
borderRadius: string;
|
|
19
|
+
backgroundColor: string;
|
|
20
|
+
transform: string;
|
|
21
|
+
opacity: number;
|
|
22
|
+
animationName: string;
|
|
23
|
+
animationTimingFunction: string;
|
|
24
|
+
animationFillMode: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export { rippleHostStyles, };
|
|
28
|
+
//# sourceMappingURL=useRipple.styled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRipple.styled.d.ts","sourceRoot":"","sources":["../../src/utils/useRipple.styled.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrB,CAAC;AAEF,OAAO,EACH,gBAAgB,GACnB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { keyframes } from "../theme.js";
|
|
2
|
+
const rippleKeyframes = keyframes({
|
|
3
|
+
"0%": { transform: "scale(0)", opacity: 0.35 },
|
|
4
|
+
"100%": { transform: "scale(1)", opacity: 0 },
|
|
5
|
+
});
|
|
6
|
+
const rippleHostStyles = {
|
|
7
|
+
"position": "relative",
|
|
8
|
+
"overflow": "hidden",
|
|
9
|
+
"WebkitTapHighlightColor": "transparent",
|
|
10
|
+
"transition": "box-shadow 150ms ease-out",
|
|
11
|
+
"&:where(a, button):hover:not(:disabled):not([aria-disabled='true'])": {
|
|
12
|
+
boxShadow: "inset 0 0 0 9999px color-mix(in srgb, currentColor calc(6% * var(--miui-ripple, 1)), transparent)",
|
|
13
|
+
},
|
|
14
|
+
"&:where(a, button):active:not(:disabled):not([aria-disabled='true'])": {
|
|
15
|
+
boxShadow: "inset 0 0 0 9999px color-mix(in srgb, currentColor calc(12% * var(--miui-ripple, 1)), transparent)",
|
|
16
|
+
},
|
|
17
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
18
|
+
transition: "none",
|
|
19
|
+
},
|
|
20
|
+
"& > span[data-miui-ripple]": {
|
|
21
|
+
position: "absolute",
|
|
22
|
+
pointerEvents: "none",
|
|
23
|
+
borderRadius: "50%",
|
|
24
|
+
backgroundColor: "currentColor",
|
|
25
|
+
transform: "scale(0)",
|
|
26
|
+
opacity: 0,
|
|
27
|
+
animationName: String(rippleKeyframes),
|
|
28
|
+
animationTimingFunction: "ease-out",
|
|
29
|
+
animationFillMode: "forwards",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export { rippleHostStyles, };
|
|
33
|
+
//# sourceMappingURL=useRipple.styled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRipple.styled.js","sourceRoot":"","sources":["../../src/utils/useRipple.styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,eAAe,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE;IAC9C,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE;CAChD,CAAC,CAAC;AAaH,MAAM,gBAAgB,GAAG;IACrB,UAAU,EAAE,UAAU;IACtB,UAAU,EAAE,QAAQ;IACpB,yBAAyB,EAAE,aAAa;IACxC,YAAY,EAAE,2BAA2B;IAOzC,qEAAqE,EAAE;QACnE,SAAS,EAAE,mGAAmG;KACjH;IACD,sEAAsE,EAAE;QACpE,SAAS,EAAE,oGAAoG;KAClH;IAED,yCAAyC,EAAE;QACvC,UAAU,EAAE,MAAM;KACrB;IAED,4BAA4B,EAAE;QAC1B,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,MAAM;QACrB,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,cAAc;QAC/B,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,CAAC;QACV,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC;QACtC,uBAAuB,EAAE,UAAU;QACnC,iBAAiB,EAAE,UAAU;KAChC;CACJ,CAAC;AAEF,OAAO,EACH,gBAAgB,GACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { borderPxToRem, css, pxToRem, styled } from "../../../theme";
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
2
3
|
import { Icon } from "../../icons/Icon";
|
|
3
4
|
|
|
4
|
-
const sharedStyles = css({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"&:hover": {
|
|
16
|
-
background: "#00000022",
|
|
17
|
-
},
|
|
18
|
-
"&:active": {
|
|
19
|
-
background: "#00000011",
|
|
20
|
-
color: "currentColor",
|
|
21
|
-
},
|
|
5
|
+
const sharedStyles = css(rippleHostStyles, {
|
|
6
|
+
width: pxToRem(30),
|
|
7
|
+
height: pxToRem(30),
|
|
8
|
+
background: "none",
|
|
9
|
+
borderRadius: "666px",
|
|
10
|
+
display: "inline-flex",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "center",
|
|
13
|
+
border: borderPxToRem(2),
|
|
14
|
+
color: "currentColor",
|
|
22
15
|
});
|
|
23
16
|
|
|
24
17
|
const Btn = styled("button", sharedStyles);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
3
5
|
import type { ReactNode } from "react";
|
|
4
6
|
import type { ICON } from "../../icons/Icon";
|
|
5
7
|
|
|
8
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
6
9
|
import { A, Btn, sharedStyles, StyledIcon } from "./HeaderIconAction.styled";
|
|
7
10
|
|
|
8
11
|
interface LinkProps { // @TODO extract? - same on list item
|
|
@@ -41,8 +44,10 @@ interface Props {
|
|
|
41
44
|
* Use this component if you need a clickable icon that stylistically fits the header.
|
|
42
45
|
* It can be a simple link, a button or a custom link component.
|
|
43
46
|
*/
|
|
44
|
-
const HeaderIconAction = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props>((props, ref) => {
|
|
47
|
+
const HeaderIconAction = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props>((props, ref) => { // eslint-disable-line max-lines-per-function
|
|
45
48
|
const { icon, href, to, Link, className, ...restProps } = props;
|
|
49
|
+
const innerRef = useForwardedRef<HTMLAnchorElement | HTMLButtonElement | null>(ref);
|
|
50
|
+
const ripple = useRipple({ ref: innerRef });
|
|
46
51
|
|
|
47
52
|
let content: ReactNode = icon;
|
|
48
53
|
if (typeof icon === "string") {
|
|
@@ -56,23 +61,45 @@ const HeaderIconAction = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props
|
|
|
56
61
|
|
|
57
62
|
return (
|
|
58
63
|
<Link href={to} {...restProps}>
|
|
59
|
-
<A
|
|
64
|
+
<A
|
|
65
|
+
ref={innerRef as React.Ref<HTMLAnchorElement>}
|
|
66
|
+
className={props.className}
|
|
67
|
+
onPointerDown={ripple.onPointerDown}
|
|
68
|
+
onKeyDown={ripple.onKeyDown}
|
|
69
|
+
>
|
|
70
|
+
{content}
|
|
71
|
+
{ripple.ripples}
|
|
72
|
+
</A>
|
|
60
73
|
</Link>
|
|
61
74
|
);
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
if (href) {
|
|
65
78
|
return (
|
|
66
|
-
<A
|
|
79
|
+
<A
|
|
80
|
+
ref={innerRef as React.Ref<HTMLAnchorElement>}
|
|
81
|
+
href={href}
|
|
82
|
+
className={props.className}
|
|
83
|
+
onPointerDown={ripple.onPointerDown}
|
|
84
|
+
onKeyDown={ripple.onKeyDown}
|
|
85
|
+
{...restProps}
|
|
86
|
+
>
|
|
67
87
|
{content}
|
|
88
|
+
{ripple.ripples}
|
|
68
89
|
</A>
|
|
69
90
|
);
|
|
70
91
|
}
|
|
71
92
|
|
|
72
93
|
return (
|
|
73
|
-
|
|
74
|
-
|
|
94
|
+
<Btn
|
|
95
|
+
ref={innerRef as React.Ref<HTMLButtonElement>}
|
|
96
|
+
className={props.className}
|
|
97
|
+
onClick={props.onClick}
|
|
98
|
+
onPointerDown={ripple.onPointerDown}
|
|
99
|
+
onKeyDown={ripple.onKeyDown}
|
|
100
|
+
>
|
|
75
101
|
{content}
|
|
102
|
+
{ripple.ripples}
|
|
76
103
|
</Btn>
|
|
77
104
|
);
|
|
78
105
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { css, dimensionsPxToRem, fontPxToRem, pxToRem, styled } from "../../../theme";
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
2
3
|
import { Icon } from "../../icons/Icon";
|
|
3
4
|
|
|
4
|
-
const StyledInnerContainer = styled("div", {
|
|
5
|
+
const StyledInnerContainer = styled("div", rippleHostStyles, {
|
|
5
6
|
display: "flex",
|
|
6
7
|
minHeight: dimensionsPxToRem(174),
|
|
7
8
|
alignItems: "center",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
1
|
+
import React, { forwardRef, useRef } from "react";
|
|
2
2
|
|
|
3
3
|
import { fnWithProps } from "../../../types/fnWithProps";
|
|
4
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
4
5
|
import { ICON } from "../../icons/Icon";
|
|
5
6
|
import { StyledIcon, StyledInnerContainer, StyledItem, StyledNoIcon } from "./Item.styled";
|
|
6
7
|
import { Label } from "./Label";
|
|
@@ -68,7 +69,10 @@ type StyledItemProps = React.ComponentProps<typeof StyledItem>;
|
|
|
68
69
|
*/
|
|
69
70
|
const ItemBase = forwardRef<
|
|
70
71
|
HTMLLIElement, StyledItemProps & Props
|
|
71
|
-
>(({ href, to, onClick, Link, ratio, ...props }, ref) => {
|
|
72
|
+
>(({ href, to, onClick, Link, ratio, ...props }, ref) => { // eslint-disable-line max-lines-per-function
|
|
73
|
+
const innerRef = useRef<HTMLElement | null>(null);
|
|
74
|
+
const ripple = useRipple({ ref: innerRef });
|
|
75
|
+
|
|
72
76
|
const r = ratio ? ratio.split("/") : [];
|
|
73
77
|
|
|
74
78
|
const pre = typeof props.selected === "boolean"
|
|
@@ -92,6 +96,11 @@ const ItemBase = forwardRef<
|
|
|
92
96
|
});
|
|
93
97
|
}) ?? [];
|
|
94
98
|
|
|
99
|
+
const interactive = Boolean(onClick ?? href ?? to);
|
|
100
|
+
const rippleProps = interactive
|
|
101
|
+
? { onPointerDown: ripple.onPointerDown, onKeyDown: ripple.onKeyDown }
|
|
102
|
+
: {};
|
|
103
|
+
|
|
95
104
|
if (to) {
|
|
96
105
|
if (!Link) {
|
|
97
106
|
throw new TypeError("`to` prop given without `Link` component");
|
|
@@ -99,7 +108,16 @@ const ItemBase = forwardRef<
|
|
|
99
108
|
|
|
100
109
|
return (
|
|
101
110
|
<StyledItem {...props} ref={ref}>
|
|
102
|
-
<Link href={to}
|
|
111
|
+
<Link href={to}>
|
|
112
|
+
<StyledInnerContainer
|
|
113
|
+
as={"a"}
|
|
114
|
+
href={to}
|
|
115
|
+
ref={innerRef as React.Ref<HTMLAnchorElement>}
|
|
116
|
+
{...rippleProps}
|
|
117
|
+
>
|
|
118
|
+
{pre}{ren}{ripple.ripples}
|
|
119
|
+
</StyledInnerContainer>
|
|
120
|
+
</Link>
|
|
103
121
|
</StyledItem>
|
|
104
122
|
);
|
|
105
123
|
}
|
|
@@ -107,7 +125,15 @@ const ItemBase = forwardRef<
|
|
|
107
125
|
if (href) {
|
|
108
126
|
return (
|
|
109
127
|
<StyledItem {...props} ref={ref}>
|
|
110
|
-
<StyledInnerContainer
|
|
128
|
+
<StyledInnerContainer
|
|
129
|
+
as={"a"}
|
|
130
|
+
href={href}
|
|
131
|
+
onClick={onClick}
|
|
132
|
+
ref={innerRef as React.Ref<HTMLAnchorElement>}
|
|
133
|
+
{...rippleProps}
|
|
134
|
+
>
|
|
135
|
+
{pre}{ren}{ripple.ripples}
|
|
136
|
+
</StyledInnerContainer>
|
|
111
137
|
</StyledItem>
|
|
112
138
|
);
|
|
113
139
|
}
|
|
@@ -115,7 +141,14 @@ const ItemBase = forwardRef<
|
|
|
115
141
|
if (onClick) {
|
|
116
142
|
return (
|
|
117
143
|
<StyledItem {...props} ref={ref}>
|
|
118
|
-
<StyledInnerContainer
|
|
144
|
+
<StyledInnerContainer
|
|
145
|
+
as={"button"}
|
|
146
|
+
onClick={onClick}
|
|
147
|
+
ref={innerRef as React.Ref<HTMLButtonElement>}
|
|
148
|
+
{...rippleProps}
|
|
149
|
+
>
|
|
150
|
+
{pre}{ren}{ripple.ripples}
|
|
151
|
+
</StyledInnerContainer>
|
|
119
152
|
</StyledItem>
|
|
120
153
|
);
|
|
121
154
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { borderPxToRem, dimensionsPxToRem, fontPxToRem, pxToRem, styled } from "../../../theme";
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Call-to-action button.
|
|
5
6
|
*/
|
|
6
|
-
const
|
|
7
|
+
const StyledButton = styled("button", rippleHostStyles, {
|
|
7
8
|
"height": dimensionsPxToRem(118),
|
|
8
9
|
"background": "$green1",
|
|
9
10
|
"border": `${borderPxToRem(1)} solid $green1Darker`,
|
|
@@ -39,5 +40,5 @@ const Button = styled("button", {
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export {
|
|
42
|
-
|
|
43
|
+
StyledButton,
|
|
43
44
|
};
|
|
@@ -1 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
6
|
+
import { StyledButton } from "./Button.styled";
|
|
7
|
+
|
|
8
|
+
type Props = React.ComponentProps<typeof StyledButton>;
|
|
9
|
+
|
|
10
|
+
const Button = forwardRef<HTMLButtonElement, Props>((props, ref) => {
|
|
11
|
+
const { children, onPointerDown, onKeyDown, ...rest } = props;
|
|
12
|
+
const innerRef = useForwardedRef(ref);
|
|
13
|
+
const ripple = useRipple({ ref: innerRef, onPointerDown, onKeyDown });
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<StyledButton
|
|
17
|
+
ref={innerRef}
|
|
18
|
+
onPointerDown={ripple.onPointerDown}
|
|
19
|
+
onKeyDown={ripple.onKeyDown}
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
{ripple.ripples}
|
|
24
|
+
</StyledButton>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
Button.displayName = "Button";
|
|
29
|
+
Button.toString = () => StyledButton.toString();
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
Button,
|
|
33
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
3
6
|
import { StyledButton, StyledDot } from "./Button.styled";
|
|
4
7
|
|
|
5
8
|
type PadButtonProps = {
|
|
@@ -7,9 +10,18 @@ type PadButtonProps = {
|
|
|
7
10
|
};
|
|
8
11
|
|
|
9
12
|
const PadButton = forwardRef<HTMLButtonElement, PadButtonProps>((props, ref) => {
|
|
13
|
+
const innerRef = useForwardedRef(ref);
|
|
14
|
+
const ripple = useRipple({ ref: innerRef, fromCenter: true });
|
|
15
|
+
|
|
10
16
|
return (
|
|
11
|
-
<StyledButton
|
|
17
|
+
<StyledButton
|
|
18
|
+
{...props}
|
|
19
|
+
ref={innerRef}
|
|
20
|
+
onPointerDown={ripple.onPointerDown}
|
|
21
|
+
onKeyDown={ripple.onKeyDown}
|
|
22
|
+
>
|
|
12
23
|
<StyledDot />
|
|
24
|
+
{ripple.ripples}
|
|
13
25
|
</StyledButton>
|
|
14
26
|
);
|
|
15
27
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { styled } from "../../../theme";
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
2
3
|
|
|
3
|
-
const StyledMiddle = styled("button", {
|
|
4
|
+
const StyledMiddle = styled("button", rippleHostStyles, {
|
|
4
5
|
display: "flex",
|
|
5
6
|
alignItems: "center",
|
|
6
7
|
justifyContent: "center",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
3
6
|
import { StyledMiddle } from "./Middle.styled";
|
|
4
7
|
|
|
5
8
|
type PadMiddleProps = {
|
|
@@ -8,9 +11,18 @@ type PadMiddleProps = {
|
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
const PadMiddle = forwardRef<HTMLButtonElement, PadMiddleProps>((props, ref) => {
|
|
14
|
+
const innerRef = useForwardedRef(ref);
|
|
15
|
+
const ripple = useRipple({ ref: innerRef, fromCenter: true });
|
|
16
|
+
|
|
11
17
|
return (
|
|
12
|
-
<StyledMiddle
|
|
18
|
+
<StyledMiddle
|
|
19
|
+
onClick={props.onClick}
|
|
20
|
+
ref={innerRef}
|
|
21
|
+
onPointerDown={ripple.onPointerDown}
|
|
22
|
+
onKeyDown={ripple.onKeyDown}
|
|
23
|
+
>
|
|
13
24
|
{props.label}
|
|
25
|
+
{ripple.ripples}
|
|
14
26
|
</StyledMiddle>
|
|
15
27
|
);
|
|
16
28
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dimensionsPxToRem, styled } from "../../../theme";
|
|
2
|
-
import {
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
3
3
|
import { NEGATIVE_PADDING } from "./Modal.styled";
|
|
4
4
|
|
|
5
5
|
const Container = styled("div", {
|
|
@@ -9,7 +9,7 @@ const Container = styled("div", {
|
|
|
9
9
|
marginBottom: NEGATIVE_PADDING,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const StyledButton = styled("button", rippleHostStyles, {
|
|
13
13
|
"border": "none",
|
|
14
14
|
"borderTop": "1px solid $modalButtonBorder",
|
|
15
15
|
"background": "$modalButtonBg",
|
|
@@ -41,10 +41,7 @@ const Button = styled("button", {
|
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const ModalButtons = fnWithProps(Container, {
|
|
45
|
-
Button,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
44
|
export {
|
|
49
|
-
|
|
45
|
+
Container,
|
|
46
|
+
StyledButton,
|
|
50
47
|
};
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { fnWithProps } from "../../../types/fnWithProps";
|
|
6
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
7
|
+
import { Container, StyledButton } from "./ModalButtons.styled";
|
|
8
|
+
|
|
9
|
+
type ButtonProps = React.ComponentProps<typeof StyledButton>;
|
|
10
|
+
|
|
11
|
+
const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
12
|
+
const { children, onPointerDown, onKeyDown, ...rest } = props;
|
|
13
|
+
const innerRef = useForwardedRef(ref);
|
|
14
|
+
const ripple = useRipple({ ref: innerRef, onPointerDown, onKeyDown });
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<StyledButton
|
|
18
|
+
ref={innerRef}
|
|
19
|
+
onPointerDown={ripple.onPointerDown}
|
|
20
|
+
onKeyDown={ripple.onKeyDown}
|
|
21
|
+
{...rest}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
{ripple.ripples}
|
|
25
|
+
</StyledButton>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
Button.displayName = "ModalButtons.Button";
|
|
30
|
+
Button.toString = () => StyledButton.toString();
|
|
31
|
+
|
|
32
|
+
const ModalButtons = fnWithProps(Container, {
|
|
33
|
+
Button,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ModalButtons,
|
|
38
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { dimensionsPxToRem, fontPxToRem, styled } from "../../../theme";
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
2
3
|
|
|
3
4
|
const Overlay = styled("div", {
|
|
4
5
|
position: "fixed",
|
|
@@ -26,24 +27,20 @@ const ListItem = styled("li", {
|
|
|
26
27
|
},
|
|
27
28
|
});
|
|
28
29
|
|
|
29
|
-
const Button = styled("button", {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"&:hover": {
|
|
45
|
-
background: "$activeBg",
|
|
46
|
-
},
|
|
30
|
+
const Button = styled("button", rippleHostStyles, {
|
|
31
|
+
border: "none",
|
|
32
|
+
background: "$background",
|
|
33
|
+
height: dimensionsPxToRem(116),
|
|
34
|
+
padding: `0 ${dimensionsPxToRem(42)}`,
|
|
35
|
+
boxSizing: "border-box",
|
|
36
|
+
width: "100%",
|
|
37
|
+
minWidth: dimensionsPxToRem(460),
|
|
38
|
+
textAlign: "left",
|
|
39
|
+
color: "$popText",
|
|
40
|
+
fontSize: fontPxToRem(26),
|
|
41
|
+
fontWeight: "revert",
|
|
42
|
+
display: "flex",
|
|
43
|
+
alignItems: "center",
|
|
47
44
|
});
|
|
48
45
|
|
|
49
46
|
const Icon = styled("div", {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
3
6
|
import { Button, FakeIcon, Icon, ListItem } from "./Pop.styled";
|
|
4
7
|
|
|
5
8
|
interface Props {
|
|
@@ -11,13 +14,24 @@ interface Props {
|
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
const PopOption = forwardRef<HTMLLIElement, Props>((props, ref) => {
|
|
17
|
+
const buttonRef = useForwardedRef<HTMLButtonElement | null>(null);
|
|
18
|
+
const ripple = useRipple({ ref: buttonRef });
|
|
19
|
+
|
|
14
20
|
const ic = props.icon
|
|
15
21
|
? <Icon>{props.icon}</Icon>
|
|
16
22
|
: ((props.forceEmptyIcon ?? true) ? <FakeIcon /> : null);
|
|
17
23
|
|
|
18
24
|
return (
|
|
19
25
|
<ListItem ref={ref} className={props.className}>
|
|
20
|
-
<Button
|
|
26
|
+
<Button
|
|
27
|
+
ref={buttonRef}
|
|
28
|
+
onClick={props.onClick}
|
|
29
|
+
onPointerDown={ripple.onPointerDown}
|
|
30
|
+
onKeyDown={ripple.onKeyDown}
|
|
31
|
+
>
|
|
32
|
+
{ic}{props.children}
|
|
33
|
+
{ripple.ripples}
|
|
34
|
+
</Button>
|
|
21
35
|
</ListItem>
|
|
22
36
|
);
|
|
23
37
|
});
|