@crystallize/design-system 1.23.1 → 1.23.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @crystallize/design-system
2
2
 
3
+ ## 1.23.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c7ede0f: Add size prop to the Switch component
8
+
3
9
  ## 1.23.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.css CHANGED
@@ -3455,10 +3455,30 @@
3455
3455
  --tw-bg-opacity: 1;
3456
3456
  background-color: rgb(var(--c-color-cyan-100-800) / var(--tw-bg-opacity));
3457
3457
  }
3458
- .c-switch-thumb {
3459
- display: block;
3458
+ .c-switch-root-sm {
3459
+ height: 1.5rem;
3460
+ width: 2.75rem;
3461
+ }
3462
+ .c-switch-root-sm .c-switch-thumb {
3460
3463
  height: 1rem;
3461
3464
  width: 1rem;
3465
+ }
3466
+ .c-switch-root-sm .c-switch-thumb[data-state=checked] {
3467
+ transform: translateX(20px);
3468
+ }
3469
+ .c-switch-root-xs {
3470
+ height: 1.25rem;
3471
+ width: 2.25rem;
3472
+ }
3473
+ .c-switch-root-xs .c-switch-thumb {
3474
+ height: 0.875rem;
3475
+ width: 0.875rem;
3476
+ }
3477
+ .c-switch-root-xs .c-switch-thumb[data-state=checked] {
3478
+ transform: translateX(16px);
3479
+ }
3480
+ .c-switch-thumb {
3481
+ display: block;
3462
3482
  transform-origin: center;
3463
3483
  --tw-translate-x: 0.25rem;
3464
3484
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
@@ -3470,7 +3490,6 @@
3470
3490
  transition-duration: 150ms;
3471
3491
  }
3472
3492
  .c-switch-thumb[data-state=checked] {
3473
- transform: translateX(20px);
3474
3493
  --tw-bg-opacity: 1;
3475
3494
  background-color: rgb(var(--c-color-green-500-400) / var(--tw-bg-opacity));
3476
3495
  }
package/dist/index.d.ts CHANGED
@@ -447,8 +447,12 @@ type TooltipProps = TooltipStylesProps & Partial<Pick<RadixTooltip.TooltipConten
447
447
  };
448
448
  declare function Tooltip({ variant, children, content, side, align, defaultOpen, delayDuration, }: TooltipProps): JSX.Element;
449
449
 
450
- type SwitchProps = ComponentProps<typeof RadixSwitch.Root>;
451
- declare function Switch(props: SwitchProps): JSX.Element;
450
+ type SwitchStylesProps = VariantProps<typeof switchStyles>;
451
+ declare const switchStyles: (props?: ({
452
+ size?: "xs" | "sm" | null | undefined;
453
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
454
+ type SwitchProps = ComponentProps<typeof RadixSwitch.Root> & SwitchStylesProps;
455
+ declare function Switch({ size, ...props }: SwitchProps): JSX.Element;
452
456
 
453
457
  declare const Icon: {
454
458
  Add: react.ForwardRefExoticComponent<Pick<react.SVGProps<SVGSVGElement>, "string" | "style" | "clipPath" | "filter" | "mask" | "path" | "key" | "className" | "id" | "lang" | "tabIndex" | "role" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "width" | "height" | "stroke" | "strokeLinecap" | "name" | "type" | "to" | "href" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "end" | "orientation" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "alignmentBaseline" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "azimuth" | "baseFrequency" | "baselineShift" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clip" | "clipPathUnits" | "clipRule" | "colorInterpolation" | "colorInterpolationFilters" | "colorProfile" | "colorRendering" | "contentScriptType" | "contentStyleType" | "cursor" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "direction" | "display" | "divisor" | "dominantBaseline" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "exponent" | "externalResourcesRequired" | "fill" | "fillOpacity" | "fillRule" | "filterRes" | "filterUnits" | "floodColor" | "floodOpacity" | "focusable" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "format" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphOrientationVertical" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "imageRendering" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "letterSpacing" | "lightingColor" | "limitingConeAngle" | "local" | "markerEnd" | "markerHeight" | "markerMid" | "markerStart" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "offset" | "opacity" | "operator" | "order" | "orient" | "origin" | "overflow" | "overlinePosition" | "overlineThickness" | "paintOrder" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "pointerEvents" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rotate" | "rx" | "ry" | "scale" | "seed" | "shapeRendering" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "stopColor" | "stopOpacity" | "strikethroughPosition" | "strikethroughThickness" | "strokeDasharray" | "strokeDashoffset" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textAnchor" | "textDecoration" | "textLength" | "textRendering" | "transform" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeBidi" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "values" | "vectorEffect" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "visibility" | "vMathematical" | "widths" | "wordSpacing" | "writingMode" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan"> & react.RefAttributes<SVGSVGElement>>;
package/dist/index.js CHANGED
@@ -39777,12 +39777,24 @@ toast.dismiss = import_sonner.toast.dismiss;
39777
39777
  init_tooltip2();
39778
39778
 
39779
39779
  // src/switch/switch.tsx
39780
+ var import_class_variance_authority21 = require("class-variance-authority");
39780
39781
  var RadixSwitch = __toESM(require("@radix-ui/react-switch"));
39781
39782
  var import_jsx_runtime146 = require("react/jsx-runtime");
39782
- function Switch2(props) {
39783
+ var switchStyles = (0, import_class_variance_authority21.cva)(["c-switch-root"], {
39784
+ variants: {
39785
+ size: {
39786
+ xs: "c-switch-root-xs",
39787
+ sm: "c-switch-root-sm"
39788
+ }
39789
+ },
39790
+ defaultVariants: {
39791
+ size: "sm"
39792
+ }
39793
+ });
39794
+ function Switch2({ size, ...props }) {
39783
39795
  return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(RadixSwitch.Root, {
39784
39796
  ...props,
39785
- className: "c-switch-root",
39797
+ className: switchStyles({ size }),
39786
39798
  children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(RadixSwitch.Thumb, {
39787
39799
  className: "c-switch-thumb"
39788
39800
  })
package/dist/index.mjs CHANGED
@@ -455,12 +455,24 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
455
455
  toast.dismiss = sonnerToast.dismiss;
456
456
 
457
457
  // src/switch/switch.tsx
458
+ import { cva as cva7 } from "class-variance-authority";
458
459
  import * as RadixSwitch from "@radix-ui/react-switch";
459
460
  import { jsx as jsx14 } from "react/jsx-runtime";
460
- function Switch(props) {
461
+ var switchStyles = cva7(["c-switch-root"], {
462
+ variants: {
463
+ size: {
464
+ xs: "c-switch-root-xs",
465
+ sm: "c-switch-root-sm"
466
+ }
467
+ },
468
+ defaultVariants: {
469
+ size: "sm"
470
+ }
471
+ });
472
+ function Switch({ size, ...props }) {
461
473
  return /* @__PURE__ */ jsx14(RadixSwitch.Root, {
462
474
  ...props,
463
- className: "c-switch-root",
475
+ className: switchStyles({ size }),
464
476
  children: /* @__PURE__ */ jsx14(RadixSwitch.Thumb, {
465
477
  className: "c-switch-thumb"
466
478
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.23.1",
3
+ "version": "1.23.2",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,13 +1,34 @@
1
1
  .c-switch-root {
2
- /* @apply radix-state-checked:border-[#528693] radix-state-checked:bg-neptune h-4 w-7 rounded-full border border-solid border-[#52869399] bg-[#9095a84d] p-0 focus:outline-none focus:ring-1 focus:ring-[#528693] focus:ring-offset-1 disabled:opacity-40; */
3
2
  @apply relative h-6 w-11 rounded-full border border-solid border-purple-200-700 bg-purple-50-900 pl-0.5 transition-all hover:border-purple-300-600 focus:outline-none enabled:cursor-pointer disabled:opacity-40 data-[state=checked]:border-green-400-500 data-[state=checked]:bg-cyan-100-800;
3
+
4
+ &-sm {
5
+ @apply h-6 w-11;
6
+
7
+ .c-switch-thumb {
8
+ @apply h-4 w-4;
9
+
10
+ &[data-state='checked']  {
11
+ transform: translateX(20px);
12
+ }
13
+ }
14
+ }
15
+
16
+ &-xs {
17
+ @apply h-5 w-9;
18
+
19
+ .c-switch-thumb {
20
+ @apply h-3.5 w-3.5;
21
+
22
+ &[data-state='checked']  {
23
+ transform: translateX(16px);
24
+ }
25
+ }
26
+ }
4
27
  }
5
28
 
6
29
  .c-switch-thumb {
7
- /* @apply block h-4 w-4 translate-x-[1px] transform-gpu rounded-full bg-purple-200-700 transition-all data-[state=checked]:translate-x-12 data-[state=checked]:bg-green-400-500; */
8
- @apply block h-4 w-4 origin-center translate-x-1 rounded-full bg-purple-400-500 transition-all;
30
+ @apply block origin-center translate-x-1 rounded-full bg-purple-400-500 transition-all;
9
31
  &[data-state='checked']  {
10
- transform: translateX(20px);
11
32
  @apply bg-green-500-400;
12
33
  }
13
34
  }
@@ -1,11 +1,25 @@
1
1
  import type { ComponentProps } from 'react';
2
+ import { cva, VariantProps } from 'class-variance-authority';
2
3
  import * as RadixSwitch from '@radix-ui/react-switch';
3
4
 
4
- export type SwitchProps = ComponentProps<typeof RadixSwitch.Root>;
5
+ type SwitchStylesProps = VariantProps<typeof switchStyles>;
6
+ const switchStyles = cva(['c-switch-root'], {
7
+ variants: {
8
+ size: {
9
+ xs: 'c-switch-root-xs',
10
+ sm: 'c-switch-root-sm',
11
+ },
12
+ },
13
+ defaultVariants: {
14
+ size: 'sm',
15
+ },
16
+ });
5
17
 
6
- export function Switch(props: SwitchProps) {
18
+ export type SwitchProps = ComponentProps<typeof RadixSwitch.Root> & SwitchStylesProps;
19
+
20
+ export function Switch({ size, ...props }: SwitchProps) {
7
21
  return (
8
- <RadixSwitch.Root {...props} className="c-switch-root">
22
+ <RadixSwitch.Root {...props} className={switchStyles({ size })}>
9
23
  <RadixSwitch.Thumb className="c-switch-thumb" />
10
24
  </RadixSwitch.Root>
11
25
  );