From e70dd365fc29fe9c53d2fd9e22c164e44e66bbe5 Mon Sep 17 00:00:00 2001 From: Mitch Lillie Date: Tue, 10 Oct 2023 10:42:24 -0700 Subject: [PATCH] Add ProgressIndicator component --- .../src/surfaces/admin/components.ts | 2 + .../ProgressIndicator/ProgressIndicator.ts | 9 ++++ .../basic-ProgressIndicator.example.tsx | 12 +++++ .../screenshots/progressindicator-default.png | Bin 0 -> 3554 bytes .../progressindicator-thumbnail.png | Bin 0 -> 5881 bytes .../src/surfaces/admin/components.ts | 2 + .../ProgressIndicator.doc.ts | 48 ++++++++++++++++++ .../ProgressIndicator/ProgressIndicator.ts | 32 ++++++++++++ .../examples/basic-ProgressIndicator.ts | 18 +++++++ .../surfaces/admin/components/shared/index.ts | 18 +++++++ 10 files changed, 141 insertions(+) create mode 100644 packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts create mode 100644 packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.example.tsx create mode 100644 packages/ui-extensions/docs/surfaces/admin/screenshots/progressindicator-default.png create mode 100644 packages/ui-extensions/docs/surfaces/admin/screenshots/progressindicator-thumbnail.png create mode 100644 packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.doc.ts create mode 100644 packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts create mode 100644 packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.ts diff --git a/packages/ui-extensions-react/src/surfaces/admin/components.ts b/packages/ui-extensions-react/src/surfaces/admin/components.ts index a9a3e4885e..3f21e729f2 100644 --- a/packages/ui-extensions-react/src/surfaces/admin/components.ts +++ b/packages/ui-extensions-react/src/surfaces/admin/components.ts @@ -38,6 +38,8 @@ export {PasswordField} from './components/PasswordField/PasswordField'; export type {PasswordFieldProps} from './components/PasswordField/PasswordField'; export {Pressable} from './components/Pressable/Pressable'; export type {PressableProps} from './components/Pressable/Pressable'; +export {ProgressIndicator} from './components/ProgressIndicator/ProgressIndicator'; +export type {ProgressIndicatorProps} from './components/ProgressIndicator/ProgressIndicator'; export {ResourceItem} from './components/ResourceItem/ResourceItem'; export type {ResourceItemProps} from './components/ResourceItem/ResourceItem'; export {ResourceList} from './components/ResourceList/ResourceList'; diff --git a/packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts b/packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts new file mode 100644 index 0000000000..655e9ab99d --- /dev/null +++ b/packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts @@ -0,0 +1,9 @@ +import {ProgressIndicator as BaseProgressIndicator} from '@shopify/ui-extensions/admin'; +import type {ProgressIndicatorProps} from '@shopify/ui-extensions/admin'; +import {createRemoteReactComponent} from '@remote-ui/react'; + +export const ProgressIndicator = createRemoteReactComponent< + 'ProgressIndicator', + ProgressIndicatorProps +>(BaseProgressIndicator); +export type {ProgressIndicatorProps} from '@shopify/ui-extensions/admin'; diff --git a/packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.example.tsx b/packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.example.tsx new file mode 100644 index 0000000000..8b4968f5e9 --- /dev/null +++ b/packages/ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.example.tsx @@ -0,0 +1,12 @@ +import { + reactExtension, + ProgressIndicator, +} from '@shopify/ui-extensions-react/admin'; + +reactExtension('Playground', () => ); + +function App() { + return ( + + ); +} diff --git a/packages/ui-extensions/docs/surfaces/admin/screenshots/progressindicator-default.png b/packages/ui-extensions/docs/surfaces/admin/screenshots/progressindicator-default.png new file mode 100644 index 0000000000000000000000000000000000000000..ce7052d8f2eaa1ef125c734909414c36a73207d8 GIT binary patch literal 3554 zcmeHK`Bzg(7Os~-f+FrLO+b#eA|q~Wf)FIoxPX8nC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(K5WqkJk1rccV=HgqQ~ z_OYpGf(%ZLTR^DmvZT~%CavkEhE<05d}!FfMDgt)k9-<>n!zrf=;*QiX;s;IZ~QJl z@xyN`K3}F|^qPw_xm>O|X>qK(?5RqniuCNICaUJ+d{4GYl z(4Ub43prBIL%q)v9+PC^u!t&lOkRV~Z#HIzM@O?8u%uimgTc^bYm%l&)>@Cl|Mj3; zUg1++FunuWo2OxBJMjM`jxU#cZQI#ydoVdYaEc_k9EX`@Lh8E`nA>+=Ho%Qe3?SQ^ ze0-6+wR2`y|6RjDA2?9Yb7*$3?b78IFKcmc=jD;HqERJrJc6>GSF*1u4x>j!X+3O( zh-t@tdYRNa6yZ>Ehk4)kRtZO9?^E_`eei0QI|04jbB%rA>n9wJm0iud2+c8NlP+Tl z?-Po%ir3+R>}5gpWg%OYs)cWd%j)FVtMfb7z^dScJld|Bz@yzD_Zi=htHNpK?Y}UW zyOCT&@{(tbl&6lz`#K`CM95EsXTk0lOg+l(nUEpxR>l-fU#N>Il5i8PiM{y=0RanS zTEP{_Ri*HpRCaXTK))%|e27s&r;y1E`>BU_l+@#!MIkQxqZwmG_$^VY(Jx9Ocn%GF zLBGL@aZzYF}=3u8$%Sw1#^S_>o(9B(TgejNX!D|w5+3(?8<>Y_yzr7roWdHyG literal 0 HcmV?d00001 diff --git a/packages/ui-extensions/docs/surfaces/admin/screenshots/progressindicator-thumbnail.png b/packages/ui-extensions/docs/surfaces/admin/screenshots/progressindicator-thumbnail.png new file mode 100644 index 0000000000000000000000000000000000000000..302d208261229d630e8a1c69b3aa6ee65c3cdb5f GIT binary patch literal 5881 zcmeHLc~p~E7Jm_iT1Bc@79l{nNiBd}~DxIT3 z9fV*R1QJ6K2tgn$T1){=KnQC|kcdD6goGqOLc+X{_79nMnA16D{%QNYlk@Vvci(ci z-@V_x@{yaX{+q^c0s!=n9y#a%!18VYP)FX-g>Np69QYP?Dhb<0 ze2I$jaNQ4zIVPiUusnF*iG2V(NMAMg$qGny{pi7crxH-({SP8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h>+IXNR0#@K*Dj#>VXazFd@>(@8XgLuO&*+tBvst)*>H;#xbgtDm*ZNUo{)Uqn0 zV%oo~=+z7~q{v3v@?z#O$=k|v{Ourg-AA13twM5>vdMy6qmX->c8P{d!mP7~0Yd`1Ylqm^ERs$EgJqqRNVJvE;>CZ$LVM0CFV>9l$gEB(}!a z)szOqbVUMAjv=q1k{>9?nF4FG6`1M4%e|fv2WSW*KOmvTxWn*_BIa4=?)T#EtqFy` zWCc+-t&Qes+9t}Q#-4KAv&TP)Rg5m=wX8l5(b=edwti`BY-9LCCO)sQaL>7!R=BAz z)tpedYsibuMB{nR5l)mu`#~OxM!?MPA!?JP0&&i%3q0(+s!P@rOumK0=^(?I`9;Za zyJr{tRywzR>(p$Lw4fH1C0n)VlN28KNIT0VT8A58hL?Tez;i{5$%1CGR$d@u)@j0| z)1mg3S&!ziuLC3krsmzERZb_n8W$(u;v|K<2O_17yn7_#Zq7}rk#&b*NU-F#K-f3> zI(*~%hb|QSEmf4ZclYkoNv!H>zX~REaiC~p1dDpMNSyggaY-BUhbv57CljL`DUZH$_w*+Sx4@!Ne+kgg9PS+Q{P2b@VI^# zlw&=Ek~Dv}lH;aroWl(Krjab8_W_ukKy-`7#cldbQ_X+FSC6R@C?pPSrgwx9jfkLo zqafDDt`G%qhylV!-+uTXFt7qJV~Rx6#Z?Ix_@Z(bgg5y7PeqI0RN?sl5&u~`feQRR t6k7hQoj^tY9ttgg)=r=z|Gm&MiH&cj2&j&SY~dt0ddTfy@&3R|{{l%Gcvk=b literal 0 HcmV?d00001 diff --git a/packages/ui-extensions/src/surfaces/admin/components.ts b/packages/ui-extensions/src/surfaces/admin/components.ts index dc32dcb200..6f085e7c87 100644 --- a/packages/ui-extensions/src/surfaces/admin/components.ts +++ b/packages/ui-extensions/src/surfaces/admin/components.ts @@ -42,6 +42,8 @@ export {PasswordField} from './components/PasswordField/PasswordField'; export type {PasswordFieldProps} from './components/PasswordField/PasswordField'; export {Pressable} from './components/Pressable/Pressable'; export type {PressableProps} from './components/Pressable/Pressable'; +export {ProgressIndicator} from './components/ProgressIndicator/ProgressIndicator'; +export type {ProgressIndicatorProps} from './components/ProgressIndicator/ProgressIndicator'; export {ResourceItem} from './components/ResourceItem/ResourceItem'; export type {ResourceItemProps} from './components/ResourceItem/ResourceItem'; export {ResourceList} from './components/ResourceList/ResourceList'; diff --git a/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.doc.ts b/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.doc.ts new file mode 100644 index 0000000000..84305047a6 --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.doc.ts @@ -0,0 +1,48 @@ +import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'; + +const data: ReferenceEntityTemplateSchema = { + name: 'ProgressIndicator', + description: + 'Use this component to notify merchants that their action is being processed or loaded.', + requires: '', + thumbnail: 'progressindicator-thumbnail.png', + isVisualComponent: true, + type: '', + definitions: [ + { + title: 'ProgressIndicatorProps', + description: '', + type: 'ProgressIndicatorProps', + }, + ], + category: 'Components', + subCategory: 'Media', + defaultExample: { + image: 'progressindicator-default.png', + codeblock: { + title: 'Simple spinner example', + tabs: [ + { + title: 'React', + code: '../../../../../../ui-extensions-react/src/surfaces/admin/components/ProgressIndicator/examples/basic-progressindicator.example.tsx', + language: 'tsx', + }, + { + title: 'JS', + code: './examples/basic-progressindicator.example.ts', + language: 'js', + }, + ], + }, + }, + + related: [ + { + type: 'component', + name: 'Button', + url: '/docs/api/admin-extensions/components/actions/button', + }, + ], +}; + +export default data; diff --git a/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts b/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts new file mode 100644 index 0000000000..fd3b55636a --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/ProgressIndicator.ts @@ -0,0 +1,32 @@ +import {createRemoteComponent} from '@remote-ui/core'; +import {GlobalProps, SizeScale, AccessibilityLabelProps} from '../shared'; + +export interface ProgressIndicatorProps + extends GlobalProps, + AccessibilityLabelProps { + /** + * The size of the component. + */ + size: SizeScale; + + /** + * Set the color of the progress indicator. + * + * - `inherit` will take the color value from its parent, + * giving the progress indicator a monochrome appearance. + * + * @defaultValue 'inherit' + */ + tone?: 'inherit' | 'default'; + + /** + * Style of the progress indicator + * @default 'spinner' + */ + variant?: 'spinner'; +} + +export const ProgressIndicator = createRemoteComponent< + 'ProgressIndicator', + ProgressIndicatorProps +>('ProgressIndicator'); diff --git a/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.ts b/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.ts new file mode 100644 index 0000000000..1c5b343f39 --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/components/ProgressIndicator/examples/basic-ProgressIndicator.ts @@ -0,0 +1,18 @@ +import { + extension, + ProgressIndicator, +} from '@shopify/ui-extensions/admin'; + +export default extension( + 'Playground', + (root) => { + const progressIndicator = root.createComponent( + ProgressIndicator, + { + size: 'small-200', + }, + ); + + root.appendChild(progressIndicator); + }, +); diff --git a/packages/ui-extensions/src/surfaces/admin/components/shared/index.ts b/packages/ui-extensions/src/surfaces/admin/components/shared/index.ts index 9200e7c6aa..13021490e8 100644 --- a/packages/ui-extensions/src/surfaces/admin/components/shared/index.ts +++ b/packages/ui-extensions/src/surfaces/admin/components/shared/index.ts @@ -122,6 +122,15 @@ export interface MinMaxLengthProps { minLength?: number; } +export interface AccessibilityLabelProps { + /** + * A label that describes the purpose or contents of the element. When set, it will be announced + * to users using assistive technologies and will provide them with more context. When set, any + * children or `label` supplied will not be announced to screen readers. + */ + accessibilityLabel?: string; +} + export interface AccessibilityRoleProps { /** * Sets the semantic meaning of the component’s content. When set, @@ -636,6 +645,15 @@ export type SpaceScale = | '28' | '32'; +export type SizeScale = + | 'small-300' + | 'small-200' + | 'small-100' + | 'base' + | 'large-100' + | 'large-200' + | 'large-300'; + export interface AnchorProps { /** * The URL to link to.