@superwall/studio 1.1.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/LICENSE +105 -0
- package/README.md +78 -0
- package/dist/assets/index-CVKGrx00.js +11 -0
- package/dist/assets/index-D4RIpSbg.css +1 -0
- package/dist/icon.svg +5 -0
- package/dist/index.html +23 -0
- package/package.json +66 -0
- package/src/StudioApp.tsx +78 -0
- package/src/components/ActionMenu.tsx +174 -0
- package/src/components/CompareMenu.tsx +147 -0
- package/src/components/DeviceChrome.tsx +124 -0
- package/src/components/DeviceFrame.tsx +210 -0
- package/src/components/MissingProducts.tsx +46 -0
- package/src/components/OpenInApp.tsx +68 -0
- package/src/components/PaywallToasts.tsx +208 -0
- package/src/components/SidePanel.tsx +36 -0
- package/src/components/SurfaceCard.tsx +93 -0
- package/src/components/Toolbar.tsx +16 -0
- package/src/components/TopBar.tsx +41 -0
- package/src/components/VariablesPanel.tsx +200 -0
- package/src/components/controls.tsx +70 -0
- package/src/components/icons.tsx +139 -0
- package/src/index.ts +20 -0
- package/src/lib/actions.ts +79 -0
- package/src/lib/devices.ts +109 -0
- package/src/lib/events.ts +77 -0
- package/src/lib/preview.ts +39 -0
- package/src/lib/project.ts +64 -0
- package/src/lib/time.ts +21 -0
- package/src/lib/types.ts +85 -0
- package/src/main.tsx +49 -0
- package/src/screens/SurfaceEditor.tsx +498 -0
- package/src/screens/SurfaceList.tsx +156 -0
- package/src/styles.css +221 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;--font-mono:"Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-md:28rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--ease-out:cubic-bezier(0, 0, .2, 1);--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-ink:#1a1918;--color-bar:#211f1d;--color-panel:#242220;--color-cream:#fdfef6;--color-accent:#46d7d4;--color-red:#ff7474}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}:root{color-scheme:dark}::selection{background:#46d7d480}@supports (color:color-mix(in lab,red,red)){::selection{background:color-mix(in srgb,var(--color-accent) 50%,transparent)}}:focus-visible{outline:2px solid var(--color-accent);outline-offset:-2px}button{cursor:pointer}*{scrollbar-width:none}::-webkit-scrollbar{width:0;height:0;display:none}}@layer components{.sw-btn{border:1px solid #fdfef62e;justify-content:center;align-items:center;gap:7px;height:30px;padding:0 12px;display:inline-flex}@supports (color:color-mix(in lab,red,red)){.sw-btn{border:1px solid color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-btn{color:var(--color-cream);white-space:nowrap;background:0 0;font-size:.8125rem;font-weight:500;transition:background-color .15s}.sw-btn:hover{background:#fdfef60d}@supports (color:color-mix(in lab,red,red)){.sw-btn:hover{background:color-mix(in srgb,var(--color-cream) 5%,transparent)}}.sw-btn--primary{background:var(--color-cream);border-color:var(--color-cream);color:var(--color-ink)}.sw-btn--primary:hover{background:#fdfef6d9}@supports (color:color-mix(in lab,red,red)){.sw-btn--primary:hover{background:color-mix(in srgb,var(--color-cream) 85%,transparent)}}.sw-btn--icon{width:30px;padding:0}.sw-icon,.sw-btn svg,.sw-segmented svg{stroke:currentColor;fill:none;stroke-width:1.5px;stroke-linecap:round;stroke-linejoin:round;width:14px;height:14px}.sw-chip{border:1px solid #fdfef62e;align-items:center;height:20px;padding:0 7px;display:inline-flex}@supports (color:color-mix(in lab,red,red)){.sw-chip{border:1px solid color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-chip{color:var(--color-cream);white-space:nowrap}.sw-tool-label{color:#fdfef68c;font-size:.75rem;font-weight:500}@supports (color:color-mix(in lab,red,red)){.sw-tool-label{color:color-mix(in srgb,var(--color-cream) 55%,transparent)}}.sw-tool-label{white-space:nowrap}.sw-tool-label--key{font-family:var(--font-mono);letter-spacing:.04em;font-size:11px}.sw-select{appearance:none;cursor:pointer;border:1px solid #fdfef62e;height:30px;padding:0 24px 0 9px}@supports (color:color-mix(in lab,red,red)){.sw-select{border:1px solid color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-select{background:linear-gradient(45deg,#0000 50%,#fdfef68c 50%) calc(100% - 13px) 55%/4px 4px no-repeat,linear-gradient(135deg,#fdfef68c 50%,#0000 50%) calc(100% - 9px) 55%/4px 4px no-repeat}@supports (color:color-mix(in lab,red,red)){.sw-select{background:linear-gradient(45deg,transparent 50%,color-mix(in srgb,var(--color-cream) 55%,transparent) 50%) calc(100% - 13px) 55% / 4px 4px no-repeat,linear-gradient(135deg,color-mix(in srgb,var(--color-cream) 55%,transparent) 50%,transparent 50%) calc(100% - 9px) 55% / 4px 4px no-repeat}}.sw-select{color:var(--color-cream);font:inherit;background-color:#0000;font-size:.8125rem;font-weight:500}.sw-select option{background:var(--color-bar)}.sw-segmented{border:1px solid #fdfef62e;display:inline-flex}@supports (color:color-mix(in lab,red,red)){.sw-segmented{border:1px solid color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-segmented{height:30px}.sw-segmented button{color:#fdfef68c;align-items:center;gap:6px;padding:0 11px;font-size:.8125rem;font-weight:500;display:inline-flex}@supports (color:color-mix(in lab,red,red)){.sw-segmented button{color:color-mix(in srgb,var(--color-cream) 55%,transparent)}}.sw-segmented button{transition:background-color .15s,color .15s}.sw-segmented button+button{border-left:1px solid #fdfef62e}@supports (color:color-mix(in lab,red,red)){.sw-segmented button+button{border-left:1px solid color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-segmented button[aria-pressed=true]{background:var(--color-cream);color:var(--color-ink)}input[type=search]::-webkit-search-cancel-button{appearance:none;display:none}input[type=search]::-webkit-search-decoration{appearance:none;display:none}input[type=search]::-webkit-search-results-button{appearance:none;display:none}input[type=search]::-webkit-search-results-decoration{appearance:none;display:none}.sw-input{border:1px solid #fdfef62e;height:30px;padding:0 9px}@supports (color:color-mix(in lab,red,red)){.sw-input{border:1px solid color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-input{color:var(--color-cream);font:inherit;background:0 0;width:100%;font-size:.8125rem}.sw-switch{background:#fdfef62e;border-radius:9999px;width:34px;height:19px;position:relative}@supports (color:color-mix(in lab,red,red)){.sw-switch{background:color-mix(in srgb,var(--color-cream) 18%,transparent)}}.sw-switch{flex:none;transition:background-color .15s}.sw-switch[aria-checked=true]{background:var(--color-accent)}.sw-switch:after{content:"";background:var(--color-ink);border-radius:9999px;width:13px;height:13px;transition:transform .15s;position:absolute;top:3px;left:3px}.sw-switch[aria-checked=true]:after{transform:translate(15px)}}@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:0}.inset-x-0{inset-inline:0}.top-0{top:0}.top-full{top:100%}.right-0{right:0}.bottom-full{bottom:100%}.left-0{left:0}.left-1\/2{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.col-start-2{grid-column-start:2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.m-0{margin:0}.m-auto{margin:auto}.mx-auto{margin-inline:auto}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-10{margin-top:calc(var(--spacing) * 10)}.mb-1{margin-bottom:var(--spacing)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.-ml-px{margin-left:-1px}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.aspect-\[390\/844\]{aspect-ratio:390/844}.size-\[5px\]{width:5px;height:5px}.h-0\.5{height:calc(var(--spacing) * .5)}.h-2{height:calc(var(--spacing) * 2)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-11{height:calc(var(--spacing) * 11)}.h-full{height:100%}.max-h-64{max-height:calc(var(--spacing) * 64)}.min-h-0{min-height:0}.min-h-14{min-height:calc(var(--spacing) * 14)}.w-0{width:0}.w-2{width:calc(var(--spacing) * 2)}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-16{width:calc(var(--spacing) * 16)}.w-48{width:calc(var(--spacing) * 48)}.w-64{width:calc(var(--spacing) * 64)}.w-72{width:calc(var(--spacing) * 72)}.w-\[344px\]{width:344px}.w-full{width:100%}.w-px{width:1px}.max-w-\[1080px\]{max-width:1080px}.max-w-full{max-width:100%}.max-w-md{max-width:var(--container-md)}.min-w-0{min-width:0}.flex-1{flex:1}.flex-none{flex:none}.shrink-0{flex-shrink:0}.origin-top-left{transform-origin:0 0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.-rotate-90{rotate:-90deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.list-none{list-style-type:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[14px_1fr\]{grid-template-columns:14px 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-\[7px\]{gap:7px}.gap-x-2\.5{column-gap:calc(var(--spacing) * 2.5)}.self-end{align-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-cream\/10{border-color:#fdfef61a}@supports (color:color-mix(in lab,red,red)){.border-cream\/10{border-color:color-mix(in oklab,var(--color-cream) 10%,transparent)}}.border-cream\/15{border-color:#fdfef626}@supports (color:color-mix(in lab,red,red)){.border-cream\/15{border-color:color-mix(in oklab,var(--color-cream) 15%,transparent)}}.border-cream\/20{border-color:#fdfef633}@supports (color:color-mix(in lab,red,red)){.border-cream\/20{border-color:color-mix(in oklab,var(--color-cream) 20%,transparent)}}.border-red{border-color:var(--color-red)}.border-transparent{border-color:#0000}.bg-accent{background-color:var(--color-accent)}.bg-accent\/15{background-color:#46d7d426}@supports (color:color-mix(in lab,red,red)){.bg-accent\/15{background-color:color-mix(in oklab,var(--color-accent) 15%,transparent)}}.bg-bar{background-color:var(--color-bar)}.bg-black{background-color:var(--color-black)}.bg-cream\/10{background-color:#fdfef61a}@supports (color:color-mix(in lab,red,red)){.bg-cream\/10{background-color:color-mix(in oklab,var(--color-cream) 10%,transparent)}}.bg-cream\/20{background-color:#fdfef633}@supports (color:color-mix(in lab,red,red)){.bg-cream\/20{background-color:color-mix(in oklab,var(--color-cream) 20%,transparent)}}.bg-cream\/55{background-color:#fdfef68c}@supports (color:color-mix(in lab,red,red)){.bg-cream\/55{background-color:color-mix(in oklab,var(--color-cream) 55%,transparent)}}.bg-ink{background-color:var(--color-ink)}.bg-ink\/70{background-color:#1a1918b3}@supports (color:color-mix(in lab,red,red)){.bg-ink\/70{background-color:color-mix(in oklab,var(--color-ink) 70%,transparent)}}.bg-panel{background-color:var(--color-panel)}.bg-red{background-color:var(--color-red)}.bg-red\/10{background-color:#ff74741a}@supports (color:color-mix(in lab,red,red)){.bg-red\/10{background-color:color-mix(in oklab,var(--color-red) 10%,transparent)}}.bg-white{background-color:var(--color-white)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.p-12{padding:calc(var(--spacing) * 12)}.\!px-0{padding-inline:0!important}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-px{padding-block:1px}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-2\.5{padding-top:calc(var(--spacing) * 2.5)}.pt-6{padding-top:calc(var(--spacing) * 6)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pb-16{padding-bottom:calc(var(--spacing) * 16)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[0\.625rem\]{font-size:.625rem}.text-\[0\.6875rem\]{font-size:.6875rem}.text-\[0\.8125rem\]{font-size:.8125rem}.text-\[0\.9375rem\]{font-size:.9375rem}.text-\[1\.0625rem\]{font-size:1.0625rem}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.01em\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-\[0\.01em\]{--tw-tracking:.01em;letter-spacing:.01em}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent{color:var(--color-accent)}.text-cream{color:var(--color-cream)}.text-cream\/25{color:#fdfef640}@supports (color:color-mix(in lab,red,red)){.text-cream\/25{color:color-mix(in oklab,var(--color-cream) 25%,transparent)}}.text-cream\/35{color:#fdfef659}@supports (color:color-mix(in lab,red,red)){.text-cream\/35{color:color-mix(in oklab,var(--color-cream) 35%,transparent)}}.text-cream\/40{color:#fdfef666}@supports (color:color-mix(in lab,red,red)){.text-cream\/40{color:color-mix(in oklab,var(--color-cream) 40%,transparent)}}.text-cream\/45{color:#fdfef673}@supports (color:color-mix(in lab,red,red)){.text-cream\/45{color:color-mix(in oklab,var(--color-cream) 45%,transparent)}}.text-cream\/55{color:#fdfef68c}@supports (color:color-mix(in lab,red,red)){.text-cream\/55{color:color-mix(in oklab,var(--color-cream) 55%,transparent)}}.text-cream\/60{color:#fdfef699}@supports (color:color-mix(in lab,red,red)){.text-cream\/60{color:color-mix(in oklab,var(--color-cream) 60%,transparent)}}.text-cream\/70{color:#fdfef6b3}@supports (color:color-mix(in lab,red,red)){.text-cream\/70{color:color-mix(in oklab,var(--color-cream) 70%,transparent)}}.text-cream\/75{color:#fdfef6bf}@supports (color:color-mix(in lab,red,red)){.text-cream\/75{color:color-mix(in oklab,var(--color-cream) 75%,transparent)}}.text-red{color:var(--color-red)}.not-italic{font-style:normal}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow-\[0_0_0_1px\]{--tw-shadow:0 0 0 1px var(--tw-shadow-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_8px_24px_-8px\]{--tw-shadow:0 8px 24px -8px var(--tw-shadow-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-black\/60{--tw-shadow-color:#0009}@supports (color:color-mix(in lab,red,red)){.shadow-black\/60{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 60%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-cream\/25{--tw-shadow-color:#fdfef640}@supports (color:color-mix(in lab,red,red)){.shadow-cream\/25{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-cream) 25%, transparent) var(--tw-shadow-alpha), transparent)}}.transition-\[width\]{transition-property:width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:border-cream\/35:is(:where(.group):hover *){border-color:#fdfef659}@supports (color:color-mix(in lab,red,red)){.group-hover\:border-cream\/35:is(:where(.group):hover *){border-color:color-mix(in oklab,var(--color-cream) 35%,transparent)}}}.first\:mt-0:first-child{margin-top:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:bg-cream\/5:hover{background-color:#fdfef60d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-cream\/5:hover{background-color:color-mix(in oklab,var(--color-cream) 5%,transparent)}}.hover\:text-cream:hover{color:var(--color-cream)}}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}@media(prefers-reduced-motion:reduce){.motion-reduce\:transition-none{transition-property:none}}@media(min-width:40rem){.sm\:block{display:block}.sm\:grid-cols-\[repeat\(auto-fill\,minmax\(200px\,1fr\)\)\]{grid-template-columns:repeat(auto-fill,minmax(200px,1fr))}.sm\:gap-6{gap:calc(var(--spacing) * 6)}.sm\:px-0{padding-inline:0}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}.sm\:pt-10{padding-top:calc(var(--spacing) * 10)}}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}
|
package/dist/icon.svg
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="32" height="32" viewBox="-4 -3.5 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="-4" y="-3.5" width="32" height="32" fill="#0c0b0a" />
|
|
3
|
+
<path d="M11.6704 5C11.5073 5 11.3555 5.05276 11.2344 5.16513C11.1125 5.27817 11.0514 5.42445 11.0514 5.5855V5.60232L11.0714 5.75125L13.0539 15.7426L13.0555 15.7488C13.1046 15.9442 13.1995 16.1174 13.358 16.24C13.5171 16.3629 13.712 16.4131 13.9185 16.4131H15.0594C15.2494 16.4131 15.4302 16.3721 15.5831 16.2707C15.737 16.1688 15.8391 16.0214 15.8987 15.8496L17.5257 11.3752L19.1519 15.8475C19.2041 16.0053 19.3053 16.1359 19.4399 16.24C19.5973 16.3617 19.7885 16.4131 19.992 16.4131H21.1328C21.3471 16.4131 21.5474 16.3593 21.7112 16.2314C21.8739 16.1042 21.9677 15.9309 21.9997 15.7315L23.9755 5.77354C23.9947 5.71046 24 5.64489 24 5.5855C24 5.42445 23.9388 5.27817 23.817 5.16513C23.7024 5.05877 23.5588 5 23.3978 5H21.8878C21.7184 5 21.5493 5.03077 21.4102 5.12292C21.2637 5.21999 21.1825 5.36387 21.1554 5.52524L19.975 11.5351L18.7868 7.98302L18.7863 7.98162C18.7373 7.83092 18.6479 7.70169 18.5258 7.59548C18.3776 7.46658 18.1921 7.41265 17.9954 7.41265H17.0727C16.8954 7.41265 16.7284 7.45826 16.5848 7.55915C16.4435 7.65853 16.3428 7.79888 16.273 7.96065L16.2686 7.97086L15.0903 11.5328L13.8952 5.52132C13.8658 5.37127 13.7979 5.21826 13.6545 5.11853C13.519 5.02423 13.344 5 13.1803 5H11.6704Z" fill="#fdfef6" />
|
|
4
|
+
<path d="M4.52814 5.4738C4.35584 5.4738 4.19642 5.52773 4.06582 5.64024C3.92315 5.76316 3.85881 5.92813 3.85881 6.10599V6.95366C2.83079 7.10357 1.98923 7.45269 1.35342 8.01647C0.66785 8.62437 0.318771 9.37785 0.318771 10.262C0.318771 11.2182 0.652159 11.9836 1.3416 12.5186C2.00264 13.0315 3.01511 13.4261 4.3481 13.7199C5.13825 13.9161 5.72908 14.0822 6.12532 14.2182C6.51567 14.3521 6.78117 14.5002 6.94431 14.6516C7.0909 14.7876 7.16397 14.9526 7.16397 15.1651C7.16397 15.4946 7.01884 15.7501 6.69237 15.9506C6.3573 16.1564 5.83223 16.2763 5.08179 16.2763C4.41547 16.2763 3.92563 16.1609 3.58647 15.9571C3.23024 15.7429 3.01761 15.4911 2.91845 15.2068L2.90841 15.178L2.89175 15.1522C2.8128 15.0302 2.71863 14.9224 2.60337 14.8483C2.46934 14.7622 2.30612 14.7353 2.14574 14.7353H0.63577C0.466468 14.7353 0.313742 14.7947 0.191383 14.9082C0.0761004 15.0152 0 15.1548 0 15.3208V15.3266L0.000274989 15.3325C0.0250464 15.8611 0.202228 16.3559 0.524719 16.8132C0.851098 17.276 1.32453 17.6573 1.93042 17.9629C2.48333 18.2418 3.12778 18.4225 3.85881 18.5103V19.3678C3.85881 19.5457 3.92315 19.7106 4.06582 19.8336C4.19642 19.9461 4.35584 20 4.52814 20H5.56834C5.74388 20 5.91338 19.9504 6.04628 19.8271C6.18054 19.7025 6.23767 19.5395 6.23767 19.3678V18.5091C7.35069 18.3703 8.26679 18.0278 8.96789 17.4658C9.73008 16.8548 10.1133 16.0493 10.1133 15.0717C10.1133 14.4217 9.96461 13.8634 9.64687 13.4153C9.33263 12.9722 8.85545 12.6189 8.23745 12.3459C7.62637 12.0759 6.81535 11.8379 5.81195 11.6286C5.1018 11.4638 4.56552 11.3115 4.19682 11.1727C3.82908 11.0343 3.59323 10.8866 3.45964 10.7427C3.33552 10.609 3.26806 10.4395 3.26806 10.2153C3.26806 9.88594 3.39996 9.65288 3.67327 9.48384C3.96705 9.30214 4.39419 9.19754 4.98113 9.19754C5.50435 9.19754 5.91981 9.30181 6.24252 9.49397C6.57133 9.68975 6.73384 9.91251 6.78307 10.1561L6.78929 10.1869L6.80291 10.2153C6.86734 10.3498 6.96436 10.4623 7.09735 10.5388C7.22863 10.6144 7.3776 10.6451 7.5313 10.6451H9.12516C9.28819 10.6451 9.44004 10.5924 9.56116 10.48C9.683 10.367 9.74415 10.2207 9.74415 10.0596V10.0523L9.74373 10.045C9.71811 9.60534 9.54899 9.16771 9.25578 8.73469C8.95575 8.29159 8.52676 7.91112 7.98004 7.58932C7.48027 7.29517 6.8978 7.09649 6.23767 6.98853V6.10599C6.23767 5.93429 6.18054 5.77128 6.04628 5.64671C5.91338 5.52341 5.74388 5.4738 5.56834 5.4738H4.52814Z" fill="#5ff5f1" />
|
|
5
|
+
</svg>
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
6
|
+
<title>Superwall Studio</title>
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="/__studio/icon.svg" />
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
10
|
+
<link
|
|
11
|
+
href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600&family=Roboto+Mono:ital,wght@0,400;0,500;1,400;1,500&display=swap"
|
|
12
|
+
rel="stylesheet"
|
|
13
|
+
/>
|
|
14
|
+
<style>
|
|
15
|
+
body { margin: 0; background: #1a1918; }
|
|
16
|
+
</style>
|
|
17
|
+
<script type="module" crossorigin src="/__studio/assets/index-CVKGrx00.js"></script>
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/__studio/assets/index-D4RIpSbg.css">
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="root"></div>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@superwall/studio",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "The Superwall studio: paywall browsing, device preview, and editing surfaces. Shared between `superwall dev` (local studio) and the hosted dashboard.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"paywall",
|
|
7
|
+
"preview",
|
|
8
|
+
"studio",
|
|
9
|
+
"superwall"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/superwall/superwall/tree/main/packages/studio#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/superwall/superwall/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "FSL-1.1-ALv2",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/superwall/superwall.git",
|
|
19
|
+
"directory": "packages/studio"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./src/index.ts",
|
|
28
|
+
"./styles.css": "./src/styles.css",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"dev": "vite",
|
|
36
|
+
"build": "vite build",
|
|
37
|
+
"preview": "vite preview",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"test:run": "vitest --run",
|
|
41
|
+
"test:coverage": "vitest --run --coverage",
|
|
42
|
+
"clean": "rm -rf dist coverage"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"sonner": "^2.0.7"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
49
|
+
"@testing-library/react": "^16.3.0",
|
|
50
|
+
"@types/react": "^19.1.0",
|
|
51
|
+
"@types/react-dom": "^19.1.0",
|
|
52
|
+
"@vitejs/plugin-react-swc": "^4.0.0",
|
|
53
|
+
"@vitest/coverage-v8": "^3.2.0",
|
|
54
|
+
"jsdom": "^26.1.0",
|
|
55
|
+
"react": "19.1.0",
|
|
56
|
+
"react-dom": "19.1.0",
|
|
57
|
+
"tailwindcss": "^4.0.0",
|
|
58
|
+
"typescript": "5.8.3",
|
|
59
|
+
"vite": "^7.0.0",
|
|
60
|
+
"vitest": "^3.2.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
64
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SurfaceEditor } from "./screens/SurfaceEditor";
|
|
3
|
+
import { SurfaceList } from "./screens/SurfaceList";
|
|
4
|
+
import { devicePreviewPath, surfacePath } from "./lib/preview";
|
|
5
|
+
import { fetchSamples } from "./lib/actions";
|
|
6
|
+
import type { Samples, StudioSource, StudioSurface } from "./lib/types";
|
|
7
|
+
|
|
8
|
+
const surfaceFromPath = (
|
|
9
|
+
surfaces: StudioSurface[],
|
|
10
|
+
pathname: string,
|
|
11
|
+
): StudioSurface | undefined => {
|
|
12
|
+
const match = pathname.match(/^\/(?:([a-z0-9-]+)\/)?(paywall|funnel)\/([a-z0-9-]+)\/?$/);
|
|
13
|
+
if (!match) return undefined;
|
|
14
|
+
return surfaces.find(
|
|
15
|
+
(surface) =>
|
|
16
|
+
surface.kind === match[2] &&
|
|
17
|
+
surface.id === match[3] &&
|
|
18
|
+
(match[1] === undefined || surface.project === match[1]),
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const StudioApp = ({
|
|
23
|
+
source,
|
|
24
|
+
device = false,
|
|
25
|
+
openPreview = (url) => window.location.assign(url),
|
|
26
|
+
}: {
|
|
27
|
+
source: StudioSource;
|
|
28
|
+
device?: boolean;
|
|
29
|
+
openPreview?: (url: string) => void;
|
|
30
|
+
}) => {
|
|
31
|
+
const [pathname, setPathname] = React.useState(() => window.location.pathname);
|
|
32
|
+
const [samples, setSamples] = React.useState<Samples>({});
|
|
33
|
+
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const onPopState = () => setPathname(window.location.pathname);
|
|
36
|
+
window.addEventListener("popstate", onPopState);
|
|
37
|
+
return () => window.removeEventListener("popstate", onPopState);
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (source.capabilities?.actions !== true) return;
|
|
42
|
+
let cancelled = false;
|
|
43
|
+
fetchSamples().then((value) => {
|
|
44
|
+
if (!cancelled) setSamples(value);
|
|
45
|
+
});
|
|
46
|
+
return () => {
|
|
47
|
+
cancelled = true;
|
|
48
|
+
};
|
|
49
|
+
}, [source.capabilities?.actions]);
|
|
50
|
+
|
|
51
|
+
const navigate = (path: string) => {
|
|
52
|
+
window.history.pushState(null, "", path);
|
|
53
|
+
setPathname(path);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const active = device ? undefined : surfaceFromPath(source.surfaces, pathname);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="bg-ink text-cream fixed inset-0 flex flex-col font-sans text-[0.9375rem] tracking-[-0.01em] antialiased">
|
|
60
|
+
{active ? (
|
|
61
|
+
<SurfaceEditor
|
|
62
|
+
source={source}
|
|
63
|
+
surface={active}
|
|
64
|
+
samples={samples}
|
|
65
|
+
onBack={() => navigate("/")}
|
|
66
|
+
/>
|
|
67
|
+
) : (
|
|
68
|
+
<SurfaceList
|
|
69
|
+
source={source}
|
|
70
|
+
device={device}
|
|
71
|
+
onOpen={(surface) =>
|
|
72
|
+
device ? openPreview(devicePreviewPath(surface)) : navigate(surfacePath(surface))
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ChevronDownIcon } from "./icons";
|
|
3
|
+
import {
|
|
4
|
+
ACTION_STEPS,
|
|
5
|
+
STEP_LABELS,
|
|
6
|
+
type StudioActionName,
|
|
7
|
+
type StudioActionStep,
|
|
8
|
+
type StudioStepState,
|
|
9
|
+
} from "../lib/types";
|
|
10
|
+
|
|
11
|
+
const ACTIONS: readonly { name: StudioActionName; label: string; hint: string }[] = [
|
|
12
|
+
{ name: "push", label: "Push", hint: "New version, nothing live changes" },
|
|
13
|
+
{ name: "publish", label: "Publish", hint: "Push and make it live" },
|
|
14
|
+
{ name: "promote", label: "Promote", hint: "Make the latest push live" },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const labelFor = (name: StudioActionName): string =>
|
|
18
|
+
ACTIONS.find((action) => action.name === name)?.label ?? name;
|
|
19
|
+
|
|
20
|
+
const runningLabel: Record<StudioActionName, string> = {
|
|
21
|
+
push: "Pushing…",
|
|
22
|
+
publish: "Publishing…",
|
|
23
|
+
promote: "Promoting…",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ActionProgress = {
|
|
27
|
+
action: StudioActionName;
|
|
28
|
+
steps: Partial<Record<StudioActionStep, StudioStepState>>;
|
|
29
|
+
error?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const StepGlyph = ({ state }: { state: StudioStepState }) => {
|
|
33
|
+
if (state === "active") return <span className="bg-accent h-2 w-2 animate-pulse" />;
|
|
34
|
+
if (state === "done") return <span className="bg-accent h-2 w-2" />;
|
|
35
|
+
if (state === "failed") return <span className="bg-red h-2 w-2" />;
|
|
36
|
+
return <span className="bg-cream/55 h-2 w-2" />;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const ProgressPanel = ({ progress }: { progress: ActionProgress }) => {
|
|
40
|
+
const steps = ACTION_STEPS[progress.action];
|
|
41
|
+
const done = steps.filter((step) => progress.steps[step] === "done").length;
|
|
42
|
+
const failed = progress.error !== undefined;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div className="w-64">
|
|
46
|
+
<div className="border-b border-cream/10 px-3 py-2.5">
|
|
47
|
+
<div className="text-[0.8125rem] font-medium">
|
|
48
|
+
{failed
|
|
49
|
+
? `${labelFor(progress.action)} failed`
|
|
50
|
+
: done === steps.length
|
|
51
|
+
? `${labelFor(progress.action)} complete`
|
|
52
|
+
: runningLabel[progress.action]}
|
|
53
|
+
</div>
|
|
54
|
+
<div className="mt-2 h-0.5 w-full bg-cream/10">
|
|
55
|
+
<div
|
|
56
|
+
className={`h-full transition-[width] duration-300 ease-out ${failed ? "bg-red" : "bg-accent"}`}
|
|
57
|
+
style={{ width: `${(done / steps.length) * 100}%` }}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<ul className="m-0 list-none px-3 py-2">
|
|
62
|
+
{steps.map((step, index) => {
|
|
63
|
+
const state = progress.steps[step] ?? "pending";
|
|
64
|
+
return (
|
|
65
|
+
<li key={step} className="flex items-center gap-2.5 py-1.5">
|
|
66
|
+
<span
|
|
67
|
+
className={`w-4 font-mono text-[0.625rem] tabular-nums ${
|
|
68
|
+
state === "pending" ? "text-cream/25" : "text-cream/55"
|
|
69
|
+
}`}
|
|
70
|
+
>
|
|
71
|
+
{String(index + 1).padStart(2, "0")}
|
|
72
|
+
</span>
|
|
73
|
+
<span
|
|
74
|
+
className={`flex-1 text-[0.8125rem] ${
|
|
75
|
+
state === "pending" ? "text-cream/40" : "text-cream"
|
|
76
|
+
}`}
|
|
77
|
+
>
|
|
78
|
+
{STEP_LABELS[step]}
|
|
79
|
+
</span>
|
|
80
|
+
<StepGlyph state={state} />
|
|
81
|
+
</li>
|
|
82
|
+
);
|
|
83
|
+
})}
|
|
84
|
+
</ul>
|
|
85
|
+
{progress.error && (
|
|
86
|
+
<div className="text-red border-t border-cream/10 px-3 py-2.5 text-xs whitespace-pre-wrap">
|
|
87
|
+
{progress.error}
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const ActionMenu = ({
|
|
95
|
+
progress,
|
|
96
|
+
blocked,
|
|
97
|
+
onRun,
|
|
98
|
+
onBlocked,
|
|
99
|
+
}: {
|
|
100
|
+
progress: ActionProgress | undefined;
|
|
101
|
+
blocked?: string;
|
|
102
|
+
onRun: (action: StudioActionName) => void;
|
|
103
|
+
onBlocked?: () => void;
|
|
104
|
+
}) => {
|
|
105
|
+
const [selected, setSelected] = React.useState<StudioActionName>("push");
|
|
106
|
+
const [open, setOpen] = React.useState(false);
|
|
107
|
+
const menuRef = React.useRef<HTMLDivElement>(null);
|
|
108
|
+
|
|
109
|
+
const stopped = blocked !== undefined;
|
|
110
|
+
const busy =
|
|
111
|
+
progress !== undefined &&
|
|
112
|
+
progress.error === undefined &&
|
|
113
|
+
ACTION_STEPS[progress.action].some((step) => progress.steps[step] !== "done");
|
|
114
|
+
const showPanel = progress !== undefined;
|
|
115
|
+
|
|
116
|
+
React.useEffect(() => {
|
|
117
|
+
if (!open) return undefined;
|
|
118
|
+
const close = (event: MouseEvent) => {
|
|
119
|
+
if (!menuRef.current?.contains(event.target as Node)) setOpen(false);
|
|
120
|
+
};
|
|
121
|
+
window.addEventListener("mousedown", close);
|
|
122
|
+
return () => window.removeEventListener("mousedown", close);
|
|
123
|
+
}, [open]);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div className="relative flex" ref={menuRef}>
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
className="sw-btn sw-btn--primary disabled:cursor-not-allowed disabled:opacity-40"
|
|
130
|
+
disabled={busy}
|
|
131
|
+
title={blocked}
|
|
132
|
+
onClick={() => (stopped ? onBlocked?.() : onRun(selected))}
|
|
133
|
+
>
|
|
134
|
+
{busy ? runningLabel[progress.action] : labelFor(selected)}
|
|
135
|
+
</button>
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
className="sw-btn sw-btn--primary -ml-px w-6 !px-0 disabled:cursor-not-allowed disabled:opacity-40"
|
|
139
|
+
aria-label="Choose action"
|
|
140
|
+
aria-expanded={open}
|
|
141
|
+
title={blocked}
|
|
142
|
+
disabled={busy}
|
|
143
|
+
onClick={() => setOpen((value) => !value)}
|
|
144
|
+
>
|
|
145
|
+
<ChevronDownIcon />
|
|
146
|
+
</button>
|
|
147
|
+
|
|
148
|
+
{(showPanel || open) && (
|
|
149
|
+
<div className="bg-bar absolute top-full right-0 z-20 mt-1 border border-cream/20">
|
|
150
|
+
{showPanel ? (
|
|
151
|
+
<ProgressPanel progress={progress} />
|
|
152
|
+
) : (
|
|
153
|
+
<div className="w-64">
|
|
154
|
+
{ACTIONS.map((action) => (
|
|
155
|
+
<button
|
|
156
|
+
key={action.name}
|
|
157
|
+
type="button"
|
|
158
|
+
className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5"
|
|
159
|
+
onClick={() => {
|
|
160
|
+
setSelected(action.name);
|
|
161
|
+
setOpen(false);
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
<span className="text-[0.8125rem] font-medium">{action.label}</span>
|
|
165
|
+
<span className="text-xs text-cream/55">{action.hint}</span>
|
|
166
|
+
</button>
|
|
167
|
+
))}
|
|
168
|
+
</div>
|
|
169
|
+
)}
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ColumnsIcon } from "./icons";
|
|
3
|
+
import type { CompareTarget } from "../lib/types";
|
|
4
|
+
|
|
5
|
+
export type CompareOption = {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
hint: string;
|
|
9
|
+
target: CompareTarget;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Row = ({
|
|
13
|
+
label,
|
|
14
|
+
hint,
|
|
15
|
+
selected,
|
|
16
|
+
onSelect,
|
|
17
|
+
}: {
|
|
18
|
+
label: string;
|
|
19
|
+
hint: string;
|
|
20
|
+
selected: boolean;
|
|
21
|
+
onSelect: () => void;
|
|
22
|
+
}) => (
|
|
23
|
+
<button
|
|
24
|
+
type="button"
|
|
25
|
+
className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5"
|
|
26
|
+
aria-current={selected || undefined}
|
|
27
|
+
onClick={onSelect}
|
|
28
|
+
>
|
|
29
|
+
<span className="flex max-w-full items-center gap-1.5 text-[0.8125rem] font-medium">
|
|
30
|
+
<span className="truncate">{label}</span>
|
|
31
|
+
{selected && (
|
|
32
|
+
<span className="bg-accent size-[5px] shrink-0 rounded-full" aria-hidden="true" />
|
|
33
|
+
)}
|
|
34
|
+
</span>
|
|
35
|
+
<span className="max-w-full truncate text-xs text-cream/55">{hint}</span>
|
|
36
|
+
</button>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const CompareMenu = ({
|
|
40
|
+
active,
|
|
41
|
+
options,
|
|
42
|
+
onSelect,
|
|
43
|
+
}: {
|
|
44
|
+
active: CompareTarget | undefined;
|
|
45
|
+
options: CompareOption[];
|
|
46
|
+
onSelect: (target: CompareTarget | undefined) => void;
|
|
47
|
+
}) => {
|
|
48
|
+
const [open, setOpen] = React.useState(false);
|
|
49
|
+
const [query, setQuery] = React.useState("");
|
|
50
|
+
const menuRef = React.useRef<HTMLDivElement>(null);
|
|
51
|
+
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (!open) return undefined;
|
|
54
|
+
const close = (event: MouseEvent) => {
|
|
55
|
+
if (!menuRef.current?.contains(event.target as Node)) setOpen(false);
|
|
56
|
+
};
|
|
57
|
+
window.addEventListener("mousedown", close);
|
|
58
|
+
return () => window.removeEventListener("mousedown", close);
|
|
59
|
+
}, [open]);
|
|
60
|
+
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
if (!open) setQuery("");
|
|
63
|
+
}, [open]);
|
|
64
|
+
|
|
65
|
+
const activeKey =
|
|
66
|
+
active &&
|
|
67
|
+
(active.type === "live" ? "live" : `surface:${active.surface.kind}/${active.surface.id}`);
|
|
68
|
+
|
|
69
|
+
const choose = (target: CompareTarget | undefined) => {
|
|
70
|
+
setOpen(false);
|
|
71
|
+
onSelect(target);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const needle = query.trim().toLowerCase();
|
|
75
|
+
const live = options.filter((option) => option.key === "live");
|
|
76
|
+
const paywalls = options
|
|
77
|
+
.filter((option) => option.key !== "live")
|
|
78
|
+
.filter(
|
|
79
|
+
(option) => needle === "" || `${option.label} ${option.hint}`.toLowerCase().includes(needle),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div className="relative flex" ref={menuRef}>
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
className="sw-btn"
|
|
87
|
+
aria-pressed={active !== undefined}
|
|
88
|
+
aria-expanded={open}
|
|
89
|
+
onClick={() => setOpen((value) => !value)}
|
|
90
|
+
>
|
|
91
|
+
<ColumnsIcon />
|
|
92
|
+
Compare
|
|
93
|
+
</button>
|
|
94
|
+
|
|
95
|
+
{open && (
|
|
96
|
+
<div className="bg-bar absolute bottom-full left-0 z-20 mb-1 flex w-72 flex-col border border-cream/20">
|
|
97
|
+
<div className="p-2">
|
|
98
|
+
<input
|
|
99
|
+
className="sw-input"
|
|
100
|
+
type="search"
|
|
101
|
+
value={query}
|
|
102
|
+
placeholder="Search paywalls"
|
|
103
|
+
aria-label="Search paywalls"
|
|
104
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div className="max-h-64 overflow-y-auto">
|
|
109
|
+
{paywalls.length === 0 ? (
|
|
110
|
+
<span className="block px-3 pt-2 pb-4 text-[0.8125rem] text-cream/45">
|
|
111
|
+
{needle === "" ? "No other paywalls here." : `Nothing matches “${query.trim()}”.`}
|
|
112
|
+
</span>
|
|
113
|
+
) : (
|
|
114
|
+
paywalls.map((option) => (
|
|
115
|
+
<Row
|
|
116
|
+
key={option.key}
|
|
117
|
+
label={option.label}
|
|
118
|
+
hint={option.hint}
|
|
119
|
+
selected={option.key === activeKey}
|
|
120
|
+
onSelect={() => choose(option.target)}
|
|
121
|
+
/>
|
|
122
|
+
))
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<div className="flex flex-col border-t border-cream/10">
|
|
127
|
+
{live.map((option) => (
|
|
128
|
+
<Row
|
|
129
|
+
key={option.key}
|
|
130
|
+
label={option.label}
|
|
131
|
+
hint={option.hint}
|
|
132
|
+
selected={option.key === activeKey}
|
|
133
|
+
onSelect={() => choose(option.target)}
|
|
134
|
+
/>
|
|
135
|
+
))}
|
|
136
|
+
<Row
|
|
137
|
+
label="Off"
|
|
138
|
+
hint="A single preview"
|
|
139
|
+
selected={active === undefined}
|
|
140
|
+
onSelect={() => choose(undefined)}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
};
|