@crystallize/design-system 1.24.7 → 1.24.9

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,17 @@
1
1
  # @crystallize/design-system
2
2
 
3
+ ## 1.24.9
4
+
5
+ ### Patch Changes
6
+
7
+ - f8a34c7: Adjust switch component to allow placing thumb to middle position when checked is null
8
+
9
+ ## 1.24.8
10
+
11
+ ### Patch Changes
12
+
13
+ - a074c5e: Add c-icon-fill to the new multiple choice component.
14
+
3
15
  ## 1.24.7
4
16
 
5
17
  ### Patch Changes
@@ -713,7 +713,7 @@ var Caret = forwardRef13((delegated, ref) => {
713
713
  width: "8",
714
714
  height: "8",
715
715
  viewBox: "0 0 8 8",
716
- fill: "none",
716
+ fill: "#626778",
717
717
  ...delegated,
718
718
  children: /* @__PURE__ */ jsx19("path", {
719
719
  d: "M4.36763 6.81306C4.21367 7.07973 3.82877 7.07973 3.67481 6.81306L0.921902 2.04489C0.767942 1.77822 0.960391 1.44489 1.26831 1.44489L6.77412 1.44489C7.08204 1.44489 7.27449 1.77822 7.12053 2.04489L4.36763 6.81306Z"
@@ -3420,6 +3420,7 @@ var MultipleChoice = forwardRef62((delegated, ref) => {
3420
3420
  }),
3421
3421
  /* @__PURE__ */ jsx68("path", {
3422
3422
  fill: "#BFF6F8",
3423
+ className: "c-icon-fill",
3423
3424
  d: "M10.227 8.842a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926l-7.811 3.056a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
3424
3425
  }),
3425
3426
  /* @__PURE__ */ jsx68("path", {
@@ -3440,6 +3441,7 @@ var MultipleChoice = forwardRef62((delegated, ref) => {
3440
3441
  }),
3441
3442
  /* @__PURE__ */ jsx68("path", {
3442
3443
  fill: "#BFF6F8",
3444
+ className: "c-icon-fill",
3443
3445
  d: "M10.227 2.528a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926L11.729 9.77a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
3444
3446
  }),
3445
3447
  /* @__PURE__ */ jsx68("path", {
package/dist/index.css CHANGED
@@ -3531,6 +3531,9 @@
3531
3531
  height: 1rem;
3532
3532
  width: 1rem;
3533
3533
  }
3534
+ .c-switch-root-sm .c-switch-thumb.middle-position {
3535
+ transform: translateX(11px);
3536
+ }
3534
3537
  .c-switch-root-sm .c-switch-thumb[data-state=checked] {
3535
3538
  transform: translateX(20px);
3536
3539
  }
@@ -3542,6 +3545,9 @@
3542
3545
  height: 0.875rem;
3543
3546
  width: 0.875rem;
3544
3547
  }
3548
+ .c-switch-root-xs .c-switch-thumb.middle-position {
3549
+ transform: translateX(8px);
3550
+ }
3545
3551
  .c-switch-root-xs .c-switch-thumb[data-state=checked] {
3546
3552
  transform: translateX(16px);
3547
3553
  }
@@ -3552,12 +3558,15 @@
3552
3558
  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));
3553
3559
  border-radius: 9999px;
3554
3560
  --tw-bg-opacity: 1;
3555
- background-color: rgb(var(--c-color-purple-400-500) / var(--tw-bg-opacity));
3561
+ background-color: rgb(255 255 255 / var(--tw-bg-opacity));
3556
3562
  transition-property: all;
3557
3563
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
3558
3564
  transition-duration: 150ms;
3559
3565
  }
3560
3566
  .c-switch-thumb[data-state=checked] {
3561
3567
  --tw-bg-opacity: 1;
3562
- background-color: rgb(var(--c-color-green-500-400) / var(--tw-bg-opacity));
3568
+ background-color: rgb(255 255 255 / var(--tw-bg-opacity));
3569
+ }
3570
+ .c-switch-thumb {
3571
+ box-shadow: 0px 1px 2px 0px rgba(40, 41, 61, 0.2), 0px 2px 4px 0px rgba(96, 97, 112, 0.2);
3563
3572
  }
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ import * as _radix_ui_react_select from '@radix-ui/react-select';
15
15
  import * as SliderPrimitive from '@radix-ui/react-slider';
16
16
  export { Toaster } from 'sonner';
17
17
  import * as RadixTooltip from '@radix-ui/react-tooltip';
18
- import * as RadixSwitch from '@radix-ui/react-switch';
18
+ import { SwitchProps } from '@radix-ui/react-switch';
19
19
 
20
20
  type SeparatorProps = HTMLAttributes<HTMLLIElement>;
21
21
  declare function Separator({ className }: SeparatorProps): JSX.Element;
@@ -466,8 +466,10 @@ type SwitchStylesProps = VariantProps<typeof switchStyles>;
466
466
  declare const switchStyles: (props?: ({
467
467
  size?: "xs" | "sm" | null | undefined;
468
468
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
469
- type SwitchProps = ComponentProps<typeof RadixSwitch.Root> & SwitchStylesProps;
470
- declare function Switch({ size, ...props }: SwitchProps): JSX.Element;
469
+ type CustomSwitchProps = SwitchStylesProps & Exclude<SwitchProps, 'checked'> & {
470
+ checked?: boolean | null;
471
+ };
472
+ declare function Switch({ size, checked, ...props }: CustomSwitchProps): JSX.Element;
471
473
 
472
474
  declare const Icon: {
473
475
  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
@@ -911,7 +911,7 @@ var init_caret = __esm({
911
911
  width: "8",
912
912
  height: "8",
913
913
  viewBox: "0 0 8 8",
914
- fill: "none",
914
+ fill: "#626778",
915
915
  ...delegated,
916
916
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", {
917
917
  d: "M4.36763 6.81306C4.21367 7.07973 3.82877 7.07973 3.67481 6.81306L0.921902 2.04489C0.767942 1.77822 0.960391 1.44489 1.26831 1.44489L6.77412 1.44489C7.08204 1.44489 7.27449 1.77822 7.12053 2.04489L4.36763 6.81306Z"
@@ -3912,6 +3912,7 @@ var init_multiple_choice = __esm({
3912
3912
  }),
3913
3913
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", {
3914
3914
  fill: "#BFF6F8",
3915
+ className: "c-icon-fill",
3915
3916
  d: "M10.227 8.842a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926l-7.811 3.056a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
3916
3917
  }),
3917
3918
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", {
@@ -3932,6 +3933,7 @@ var init_multiple_choice = __esm({
3932
3933
  }),
3933
3934
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", {
3934
3935
  fill: "#BFF6F8",
3936
+ className: "c-icon-fill",
3935
3937
  d: "M10.227 2.528a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926L11.729 9.77a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
3936
3938
  }),
3937
3939
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", {
@@ -39935,9 +39937,8 @@ function CollapsibleTrigger({
39935
39937
  children: [
39936
39938
  arrowPosition && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Icon.Caret, {
39937
39939
  className: "c-collapsible-arrow",
39938
- fill: "purple-50-900",
39939
- width: 10,
39940
- height: 10
39940
+ width: 9,
39941
+ height: 9
39941
39942
  }),
39942
39943
  children
39943
39944
  ]
@@ -40335,12 +40336,13 @@ var switchStyles = (0, import_class_variance_authority23.cva)(["c-switch-root"],
40335
40336
  size: "sm"
40336
40337
  }
40337
40338
  });
40338
- function Switch2({ size, ...props }) {
40339
+ function Switch2({ size, checked, ...props }) {
40339
40340
  return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(RadixSwitch.Root, {
40340
40341
  ...props,
40342
+ checked,
40341
40343
  className: switchStyles({ size }),
40342
40344
  children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(RadixSwitch.Thumb, {
40343
- className: "c-switch-thumb"
40345
+ className: (0, import_class_variance_authority23.cx)("c-switch-thumb", checked === null ? "middle-position" : "")
40344
40346
  })
40345
40347
  });
40346
40348
  }
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  showError,
18
18
  showInfo,
19
19
  showWarning
20
- } from "./chunk-BNSEEMOM.mjs";
20
+ } from "./chunk-LVKSZBWB.mjs";
21
21
  import "./chunk-NIH5ZMPE.mjs";
22
22
 
23
23
  // src/card/card.tsx
@@ -139,9 +139,8 @@ function CollapsibleTrigger({
139
139
  children: [
140
140
  arrowPosition && /* @__PURE__ */ jsx4(Icon.Caret, {
141
141
  className: "c-collapsible-arrow",
142
- fill: "purple-50-900",
143
- width: 10,
144
- height: 10
142
+ width: 9,
143
+ height: 9
145
144
  }),
146
145
  children
147
146
  ]
@@ -417,7 +416,7 @@ function Tag({
417
416
  // src/rich-text-editor/index.tsx
418
417
  import { lazy, Suspense } from "react";
419
418
  import { jsx as jsx13 } from "react/jsx-runtime";
420
- var LazyRichTextEditor = lazy(() => import("./rich-text-editor-BSPSXJSK.mjs"));
419
+ var LazyRichTextEditor = lazy(() => import("./rich-text-editor-ANU6NSC2.mjs"));
421
420
  var RichTextEditor = (props) => {
422
421
  return /* @__PURE__ */ jsx13(Suspense, {
423
422
  fallback: null,
@@ -504,7 +503,7 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
504
503
  toast.dismiss = sonnerToast.dismiss;
505
504
 
506
505
  // src/switch/switch.tsx
507
- import { cva as cva7 } from "class-variance-authority";
506
+ import { cva as cva7, cx as cx8 } from "class-variance-authority";
508
507
  import * as RadixSwitch from "@radix-ui/react-switch";
509
508
  import { jsx as jsx15 } from "react/jsx-runtime";
510
509
  var switchStyles = cva7(["c-switch-root"], {
@@ -518,12 +517,13 @@ var switchStyles = cva7(["c-switch-root"], {
518
517
  size: "sm"
519
518
  }
520
519
  });
521
- function Switch({ size, ...props }) {
520
+ function Switch({ size, checked, ...props }) {
522
521
  return /* @__PURE__ */ jsx15(RadixSwitch.Root, {
523
522
  ...props,
523
+ checked,
524
524
  className: switchStyles({ size }),
525
525
  children: /* @__PURE__ */ jsx15(RadixSwitch.Thumb, {
526
- className: "c-switch-thumb"
526
+ className: cx8("c-switch-thumb", checked === null ? "middle-position" : "")
527
527
  })
528
528
  });
529
529
  }
@@ -6,7 +6,7 @@ import {
6
6
  Icon,
7
7
  IconButton,
8
8
  InputWithLabel
9
- } from "./chunk-BNSEEMOM.mjs";
9
+ } from "./chunk-LVKSZBWB.mjs";
10
10
  import "./chunk-NIH5ZMPE.mjs";
11
11
 
12
12
  // src/rich-text-editor/rich-text-editor.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.24.7",
3
+ "version": "1.24.9",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -29,7 +29,7 @@ export function CollapsibleTrigger({
29
29
  className={cx('c-collapsible-trigger', arrowPosition === 'right' ? 'arrow-right' : '', className)}
30
30
  >
31
31
  <div>
32
- {arrowPosition && <Icon.Caret className="c-collapsible-arrow" fill="purple-50-900" width={10} height={10} />}
32
+ {arrowPosition && <Icon.Caret className="c-collapsible-arrow" width={9} height={9} />}
33
33
  {children}
34
34
  </div>
35
35
  </CollapsiblePrimitives.Trigger>
@@ -6,7 +6,7 @@ type CaretRef = SVGSVGElement;
6
6
 
7
7
  export const Caret = forwardRef<CaretRef, CaretProps>((delegated, ref) => {
8
8
  return (
9
- <svg ref={ref} width="8" height="8" viewBox="0 0 8 8" fill="none" {...delegated}>
9
+ <svg ref={ref} width="8" height="8" viewBox="0 0 8 8" fill="#626778" {...delegated}>
10
10
  <path d="M4.36763 6.81306C4.21367 7.07973 3.82877 7.07973 3.67481 6.81306L0.921902 2.04489C0.767942 1.77822 0.960391 1.44489 1.26831 1.44489L6.77412 1.44489C7.08204 1.44489 7.27449 1.77822 7.12053 2.04489L4.36763 6.81306Z" />
11
11
  </svg>
12
12
  );
@@ -16,6 +16,7 @@ export const MultipleChoice = forwardRef<MultipleChoiceRef, MultipleChoiceProps>
16
16
  />
17
17
  <path
18
18
  fill="#BFF6F8"
19
+ className="c-icon-fill"
19
20
  d="M10.227 8.842a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926l-7.811 3.056a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
20
21
  />
21
22
  <path
@@ -36,6 +37,7 @@ export const MultipleChoice = forwardRef<MultipleChoiceRef, MultipleChoiceProps>
36
37
  />
37
38
  <path
38
39
  fill="#BFF6F8"
40
+ className="c-icon-fill"
39
41
  d="M10.227 2.528a2 2 0 0 1 1.546 0l7.778 3.26a.5.5 0 0 1-.011.926L11.729 9.77a2 2 0 0 1-1.458 0l-7.81-3.056a.5.5 0 0 1-.012-.927l7.778-3.26Z"
40
42
  />
41
43
  <path
@@ -39,6 +39,20 @@ export function Controlled() {
39
39
  );
40
40
  }
41
41
 
42
+ export function DefaultCenter() {
43
+ const [checked, setChecked] = useState<boolean | null>(null);
44
+
45
+ return (
46
+ <div style={style}>
47
+ <Switch checked={checked} onCheckedChange={c => setChecked(c)} />
48
+
49
+ <button onClick={() => setChecked(null)} style={{ marginLeft: '16px' }}>
50
+ Set Null
51
+ </button>
52
+ </div>
53
+ );
54
+ }
55
+
42
56
  export const WithLabel = () => {
43
57
  return (
44
58
  <div style={{ display: 'flex', padding: '3rem', gap: '0.5rem', alignItems: 'center' }}>
@@ -7,6 +7,10 @@
7
7
  .c-switch-thumb {
8
8
  @apply h-4 w-4;
9
9
 
10
+ &.middle-position {
11
+ transform: translateX(11px);
12
+ }
13
+
10
14
  &[data-state='checked']  {
11
15
  transform: translateX(20px);
12
16
  }
@@ -19,6 +23,10 @@
19
23
  .c-switch-thumb {
20
24
  @apply h-3.5 w-3.5;
21
25
 
26
+ &.middle-position {
27
+ transform: translateX(8px);
28
+ }
29
+
22
30
  &[data-state='checked']  {
23
31
  transform: translateX(16px);
24
32
  }
@@ -27,8 +35,9 @@
27
35
  }
28
36
 
29
37
  .c-switch-thumb {
30
- @apply block origin-center translate-x-1 rounded-full bg-purple-400-500 transition-all;
38
+ @apply block origin-center translate-x-1 rounded-full bg-white transition-all;
31
39
  &[data-state='checked']  {
32
- @apply bg-green-500-400;
40
+ @apply bg-white;
33
41
  }
42
+ box-shadow: 0px 1px 2px 0px rgba(40, 41, 61, 0.2), 0px 2px 4px 0px rgba(96, 97, 112, 0.2);
34
43
  }
@@ -1,6 +1,6 @@
1
- import type { ComponentProps } from 'react';
2
- import { cva, VariantProps } from 'class-variance-authority';
1
+ import { cva, VariantProps, cx } from 'class-variance-authority';
3
2
  import * as RadixSwitch from '@radix-ui/react-switch';
3
+ import type { SwitchProps } from '@radix-ui/react-switch';
4
4
 
5
5
  type SwitchStylesProps = VariantProps<typeof switchStyles>;
6
6
  const switchStyles = cva(['c-switch-root'], {
@@ -15,12 +15,15 @@ const switchStyles = cva(['c-switch-root'], {
15
15
  },
16
16
  });
17
17
 
18
- export type SwitchProps = ComponentProps<typeof RadixSwitch.Root> & SwitchStylesProps;
18
+ export type CustomSwitchProps = SwitchStylesProps &
19
+ Exclude<SwitchProps, 'checked'> & {
20
+ checked?: boolean | null;
21
+ };
19
22
 
20
- export function Switch({ size, ...props }: SwitchProps) {
23
+ export function Switch({ size, checked, ...props }: CustomSwitchProps) {
21
24
  return (
22
- <RadixSwitch.Root {...props} className={switchStyles({ size })}>
23
- <RadixSwitch.Thumb className="c-switch-thumb" />
25
+ <RadixSwitch.Root {...props} checked={checked} className={switchStyles({ size })}>
26
+ <RadixSwitch.Thumb className={cx('c-switch-thumb', checked === null ? 'middle-position' : '')} />
24
27
  </RadixSwitch.Root>
25
28
  );
26
29
  }