From 3f5f8b450fd3a0b51cdcd93c662ef85579542e2a Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:23:47 +1000 Subject: [PATCH] Create SliderControl relocating Slider as internal only component Update snapshots Remove comments --- .../components/src/slider-control/index.ts | 2 + .../src/slider-control/mark/component.tsx | 48 + .../src/slider-control/mark/hook.ts | 38 + .../src/slider-control/marks/component.tsx | 36 + .../src/slider-control/marks/hook.ts | 43 + .../slider-control/marks/use-marks-data.ts | 53 + .../slider-control/component.tsx | 130 ++ .../src/slider-control/slider-control/hook.ts | 93 ++ .../slider/component.tsx | 14 - .../{slider => slider-control}/slider/hook.ts | 39 +- .../src/slider-control/stories/index.tsx | 232 ++++ .../src/{slider => slider-control}/styles.ts | 162 ++- .../test/__snapshots__/index.tsx.snap | 1115 +++++++++++++++++ .../src/slider-control/test/index.tsx | 45 + .../src/slider-control/tooltip/component.tsx | 30 + .../src/slider-control/tooltip/hook.ts | 70 ++ .../components/src/slider-control/types.ts | 272 ++++ .../components/src/slider-control/utils.ts | 132 ++ packages/components/src/slider/index.ts | 2 - .../components/src/slider/stories/index.tsx | 55 - .../slider/test/__snapshots__/index.tsx.snap | 749 ----------- packages/components/src/slider/test/index.tsx | 98 -- packages/components/src/slider/types.ts | 66 - packages/components/src/utils/interpolate.ts | 2 +- .../components/src/utils/test/interpolate.ts | 104 ++ 25 files changed, 2611 insertions(+), 1019 deletions(-) create mode 100644 packages/components/src/slider-control/index.ts create mode 100644 packages/components/src/slider-control/mark/component.tsx create mode 100644 packages/components/src/slider-control/mark/hook.ts create mode 100644 packages/components/src/slider-control/marks/component.tsx create mode 100644 packages/components/src/slider-control/marks/hook.ts create mode 100644 packages/components/src/slider-control/marks/use-marks-data.ts create mode 100644 packages/components/src/slider-control/slider-control/component.tsx create mode 100644 packages/components/src/slider-control/slider-control/hook.ts rename packages/components/src/{slider => slider-control}/slider/component.tsx (68%) rename packages/components/src/{slider => slider-control}/slider/hook.ts (79%) create mode 100644 packages/components/src/slider-control/stories/index.tsx rename packages/components/src/{slider => slider-control}/styles.ts (53%) create mode 100644 packages/components/src/slider-control/test/__snapshots__/index.tsx.snap create mode 100644 packages/components/src/slider-control/test/index.tsx create mode 100644 packages/components/src/slider-control/tooltip/component.tsx create mode 100644 packages/components/src/slider-control/tooltip/hook.ts create mode 100644 packages/components/src/slider-control/types.ts create mode 100644 packages/components/src/slider-control/utils.ts delete mode 100644 packages/components/src/slider/index.ts delete mode 100644 packages/components/src/slider/stories/index.tsx delete mode 100644 packages/components/src/slider/test/__snapshots__/index.tsx.snap delete mode 100644 packages/components/src/slider/test/index.tsx delete mode 100644 packages/components/src/slider/types.ts create mode 100644 packages/components/src/utils/test/interpolate.ts diff --git a/packages/components/src/slider-control/index.ts b/packages/components/src/slider-control/index.ts new file mode 100644 index 0000000000000..dd8874dc70a4f --- /dev/null +++ b/packages/components/src/slider-control/index.ts @@ -0,0 +1,2 @@ +export { default as SliderControl } from './slider-control/component'; +export { useSliderControl } from './slider-control/hook'; diff --git a/packages/components/src/slider-control/mark/component.tsx b/packages/components/src/slider-control/mark/component.tsx new file mode 100644 index 0000000000000..02f2a5dd2f385 --- /dev/null +++ b/packages/components/src/slider-control/mark/component.tsx @@ -0,0 +1,48 @@ +/** + * Internal dependencies + */ +import { contextConnect, WordPressComponentProps } from '../../ui/context'; +import { useMark } from './hook'; +import { View } from '../../view'; + +import type { MarkProps } from '../types'; + +const UnconnectedMark = ( + props: WordPressComponentProps< MarkProps, 'span' >, + forwardedRef: React.ForwardedRef< any > +) => { + const { + className, + isFilled = false, + label, + labelClassName, + style = {}, + ...otherProps + } = useMark( props ); + + return ( + <> +