Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(website): add topbar and user dialog docs #3249

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cypress/integration/sitemap-vrt/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export const SITEMAP = [
'/components/toast/',
'/components/time-picker/',
'/components/truncate/',
'/components/user-dialog/',
'/components/topbar',
'/components/tooltip/',
'/components/textarea/',
'/core/changelog/',
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/components/topbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.2.0",
"category": "layout",
"status": "alpha",
"description": "Topbar encapsulates application-wide controls that rest at the top of the screen.",
"description": "Topbar contains application-wide controls that rest at the top of the screen.",
"author": "Twilio Inc.",
"license": "MIT",
"main:dev": "src/index.tsx",
Expand Down
2 changes: 2 additions & 0 deletions packages/paste-core/components/user-dialog/src/UserDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const UserDialogPopover = React.forwardRef<HTMLDivElement, UserDialogPopoverProp
padding="space0"
marginTop="space30"
width="size30"
zIndex="zIndex80"
outline="none"
>
{props.children}
</Box>
Expand Down
8 changes: 8 additions & 0 deletions packages/paste-core/core-bundle/progress-steps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@twilio-paste-core/progress-steps",
"version": "0.0.0",
"private": true,
"sideEffects": false,
"main": "../dist/progress-steps.js",
"types": "../dist/progress-steps.d.ts"
}
8 changes: 8 additions & 0 deletions packages/paste-core/core-bundle/user-dialog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@twilio-paste-core/user-dialog",
"version": "0.0.0",
"private": true,
"sideEffects": false,
"main": "../dist/user-dialog.js",
"types": "../dist/user-dialog.d.ts"
}
6 changes: 4 additions & 2 deletions packages/paste-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
"@twilio-paste/pagination": "^6.0.0",
"@twilio-paste/paragraph": "^9.0.0",
"@twilio-paste/popover": "^12.0.0",
"@twilio-paste/product-switcher": "1.0.0",
"@twilio-paste/progress-steps": "^1.0.0",
"@twilio-paste/product-switcher": "^1.0.0",
"@twilio-paste/progress-steps": "^0.0.0",
"@twilio-paste/radio-button-group": "^3.0.0",
"@twilio-paste/radio-group": "^12.0.0",
"@twilio-paste/react-textarea-autosize-library": "^2.0.0",
Expand Down Expand Up @@ -119,9 +119,11 @@
"@twilio-paste/toast": "^11.0.0",
"@twilio-paste/tooltip": "^10.0.0",
"@twilio-paste/tooltip-primitive": "^1.0.0",
"@twilio-paste/topbar": "^0.1.0",
"@twilio-paste/truncate": "^13.0.0",
"@twilio-paste/types": "^5.0.0",
"@twilio-paste/uid-library": "^1.0.0",
"@twilio-paste/user-dialog": "^0.0.0",
"@twilio-paste/utils": "^4.0.0",
"@types/airtable": "^0.10.1",
"@types/gtag.js": "^0.0.12",
Expand Down
226 changes: 226 additions & 0 deletions packages/paste-website/src/component-examples/TopbarExamples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
export const defaultTopbarExample = `
const TopbarExample = () => {
const [account, setAccount] = React.useState('Account name');
const menu = useMenuState();
const onClick = (newAccount) => {
menu.hide();
setAccount(newAccount);
};
const productSwitcher = useProductSwitcherState();
const [product, setProduct] = React.useState('twilio');
return (
<Topbar>
<Box display="flex" columnGap="space50">
<MenuBadge {...menu} i18nButtonLabel="Change account" variant="decorative10">
{account}
</MenuBadge>
<Menu {...menu} aria-label="Accounts">
<MenuItem {...menu} onClick={()=>onClick('Account one')}>
Account one
</MenuItem>
<MenuItem {...menu} onClick={()=>onClick('Account two')}>
Account two
</MenuItem>
<MenuItem {...menu} onClick={()=>onClick('Account three')}>
Account three
</MenuItem>
</Menu>
<Badge variant="subaccount" size="small">Subaccount</Badge>
<Box flex-shrink="4" paddingX="space150">
<Input placeholder="Search" insertBefore={<SearchIcon decorative/>}/>
</Box>
<ProductSwitcherButton {...productSwitcher} i18nButtonLabel="Switch products" />
<ProductSwitcher {...productSwitcher} aria-label="Avaiable accounts">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: The badges are stretched in the example

Screenshot 2023-06-13 at 9 46 23 AM

<ProductSwitcherItem
{...productSwitcher}
name="product"
value="twilio"
checked={product === 'twilio'}
onChange={(e) => {
setProduct('twilio');
}}
productName="Twilio"
productStrapline="SMS, Voice & Video"
productIcon={<LogoTwilioIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="segment"
checked={product === 'segment'}
onChange={(e) => {
setProduct('segment');
}}
productName="Segment"
productStrapline="Customer data platform"
productIcon={<ProductSegmentIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="flex"
checked={product === 'flex'}
onChange={(e) => {
setProduct('flex');
}}
productName="Flex"
productStrapline="Cloud-based contact center"
productIcon={<ProductFlexIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="sendgrid"
checked={product === 'sendgrid'}
onChange={(e) => {
setProduct('sendgrid');
}}
productName="SendGrid"
productStrapline="Email delivery and API"
productIcon={<ProductEmailAPIIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="admin"
checked={product === 'admin'}
onChange={(e) => {
setProduct('admin');
}}
productName="Console Admin"
productStrapline="Admin center"
productIcon={<LogoTwilioIcon decorative />}
/>
</ProductSwitcher>
</Box>
</Topbar>
)
}

render(
<TopbarExample/>
)
`.trim();

export const emptyTopbarExample = `
const TopbarExample = () => {
return (
<Topbar>I am an empty Topbar</Topbar>
)
}

render(
<TopbarExample/>
)
`.trim();

export const defaultAccountSwitcherExample = `
const AccountSwitcher = () => {
const [account, setAccount] = React.useState('Account name');
const menu = useMenuState();
const onClick = (newAccount) => {
menu.hide();
setAccount(newAccount);
};
return (
<>
nkrantz marked this conversation as resolved.
Show resolved Hide resolved
<MenuBadge {...menu} i18nButtonLabel="Change account" variant="decorative10">
{account}
</MenuBadge>
<Menu {...menu} aria-label="Accounts">
<MenuItem {...menu} onClick={()=>onClick('Account one')}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (blocking): let's update the onClick so that it actually updates account state, so it works when clicking through the demo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the onClick uses setAccount to update the account state. what should be updated?

Account one
</MenuItem>
<MenuItem {...menu} onClick={()=>onClick('Account two')}>
Account two
</MenuItem>
<MenuItem {...menu} onClick={()=>onClick('Account three')}>
Account three
</MenuItem>
</Menu>
</>
);
};

render(
<AccountSwitcher />
)
`.trim();

export const defaultProductSwitcherExample = `
const ProductSwitcherMenu = () => {
const productSwitcher = useProductSwitcherState();
const [product, setProduct] = React.useState('twilio');
return (
<>
<ProductSwitcherButton {...productSwitcher} i18nButtonLabel="Switch products" />
<ProductSwitcher {...productSwitcher} aria-label="Avaiable accounts">
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="twilio"
checked={product === 'twilio'}
onChange={(e) => {
setProduct('twilio');
}}
productName="Twilio"
productStrapline="SMS, Voice & Video"
productIcon={<LogoTwilioIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="segment"
checked={product === 'segment'}
onChange={(e) => {
setProduct('segment');
}}
productName="Segment"
productStrapline="Customer data platform"
productIcon={<ProductSegmentIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="flex"
checked={product === 'flex'}
onChange={(e) => {
setProduct('flex');
}}
productName="Flex"
productStrapline="Cloud-based contact center"
productIcon={<ProductFlexIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="sendgrid"
checked={product === 'sendgrid'}
onChange={(e) => {
setProduct('sendgrid');
}}
productName="SendGrid"
productStrapline="Email delivery and API"
productIcon={<ProductEmailAPIIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="admin"
checked={product === 'admin'}
onChange={(e) => {
setProduct('admin');
}}
productName="Console Admin"
productStrapline="Admin center"
productIcon={<LogoTwilioIcon decorative />}
/>
</ProductSwitcher>
</>
);
};

render(
<ProductSwitcherMenu />
)
`.trim();
Loading
Loading