-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fb7bdc
commit d2a846c
Showing
21 changed files
with
305 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Flex, IconCompact } from 'gestalt'; | ||
|
||
export default function Example() { | ||
return ( | ||
<Flex alignItems="center" height="100%" justifyContent="center" width="100%"> | ||
<IconCompact accessibilityLabel="Add new Pins" icon="compact-add" /> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Flex, IconCompact } from 'gestalt'; | ||
|
||
export default function Example() { | ||
return ( | ||
<Flex alignItems="center" height="100%" justifyContent="center" width="100%"> | ||
<IconCompact | ||
accessibilityLabel="Add new Pins" | ||
dangerouslySetSvgPath={{ | ||
__path: | ||
'M9.41 1.41a1.41 1.41 0 0 0-2.82 0V6.6H1.4a1.41 1.41 0 1 0 0 2.82h5.2v5.18a1.41 1.41 0 1 0 2.82 0V9.4h5.18a1.41 1.41 0 1 0 0-2.82H9.4z', | ||
}} | ||
/> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Flex, IconCompact } from 'gestalt'; | ||
|
||
export default function Example() { | ||
return ( | ||
<Flex alignItems="center" height="100%" justifyContent="center" width="100%"> | ||
<Flex alignItems="center" gap={2}> | ||
<IconCompact accessibilityLabel="Pin" icon="compact-add" /> | ||
</Flex> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Box, ColorSchemeProvider, Flex, IconCompact, Text } from 'gestalt'; | ||
import icons from 'gestalt/src/icons/compact'; | ||
|
||
export default function Snapshot() { | ||
return ( | ||
<ColorSchemeProvider colorScheme="dark"> | ||
<Box color="default" height={2000} width={2000}> | ||
<Flex | ||
gap={{ | ||
row: 1, | ||
column: 0, | ||
}} | ||
wrap | ||
> | ||
{Object.keys(icons).map((name, idk) => ( | ||
<Box key={name} padding={2} width={100}> | ||
<Text size="100">{idk}</Text> | ||
{/* @ts-expect-error - TS2322 */} | ||
<IconCompact accessibilityLabel="" color="default" icon={name} /> | ||
<Text size="100">{name}</Text> | ||
</Box> | ||
))} | ||
</Flex> | ||
</Box> | ||
</ColorSchemeProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Box, ColorSchemeProvider, Flex, IconCompact, Text } from 'gestalt'; | ||
import icons from 'gestalt/src/icons-vr-theme/compact'; | ||
|
||
export default function Snapshot() { | ||
return ( | ||
<ColorSchemeProvider colorScheme="light"> | ||
<Box color="default" height={2000} width={2000}> | ||
<Flex | ||
gap={{ | ||
row: 1, | ||
column: 0, | ||
}} | ||
wrap | ||
> | ||
{Object.keys(icons).map((name, idk) => ( | ||
<Box key={name} padding={2} width={100}> | ||
<Text size="100">{idk}</Text> | ||
{/* @ts-expect-error - TS2322 */} | ||
<IconCompact accessibilityLabel="" color="default" icon={name} /> | ||
<Text size="100">{name}</Text> | ||
</Box> | ||
))} | ||
</Flex> | ||
</Box> | ||
</ColorSchemeProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Box, ColorSchemeProvider, Flex, IconCompact, Text } from 'gestalt'; | ||
import icons from 'gestalt/src/icons/compact'; | ||
|
||
export default function Snapshot() { | ||
return ( | ||
<ColorSchemeProvider colorScheme="light"> | ||
<Box color="default" height={2000} width={2000}> | ||
<Flex | ||
gap={{ | ||
row: 1, | ||
column: 0, | ||
}} | ||
wrap | ||
> | ||
{Object.keys(icons).map((name, idk) => ( | ||
<Box key={name} padding={2} width={100}> | ||
<Text size="100">{idk}</Text> | ||
{/* @ts-expect-error - TS2322 */} | ||
<IconCompact accessibilityLabel="" color="default" icon={name} /> | ||
<Text size="100">{name}</Text> | ||
</Box> | ||
))} | ||
</Flex> | ||
</Box> | ||
</ColorSchemeProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { IconCompact } from 'gestalt'; | ||
import AccessibilitySection from '../../docs-components/AccessibilitySection'; | ||
import CombinationNew from '../../docs-components/CombinationNew'; | ||
import docGen, { DocGen, overrideTypes } from '../../docs-components/docgen'; | ||
import GeneratedPropTable from '../../docs-components/GeneratedPropTable'; | ||
import LocalizationSection from '../../docs-components/LocalizationSection'; | ||
import MainSection from '../../docs-components/MainSection'; | ||
import Page from '../../docs-components/Page'; | ||
import PageHeader from '../../docs-components/PageHeader'; | ||
import QualityChecklist from '../../docs-components/QualityChecklist'; | ||
import SandpackExample from '../../docs-components/SandpackExample'; | ||
import builtInIcon from '../../examples/iconCompact/builtInIcon'; | ||
import customIcon from '../../examples/iconCompact/customIcon'; | ||
import main from '../../examples/iconCompact/main'; | ||
|
||
const HEIGHT = 150; | ||
|
||
export default function ComponentPage({ generatedDocGen }: { generatedDocGen: DocGen }) { | ||
return ( | ||
<Page title={generatedDocGen?.displayName}> | ||
<PageHeader description={generatedDocGen?.description} name={generatedDocGen?.displayName}> | ||
<SandpackExample code={main} hideEditor name="Main example" previewHeight={HEIGHT} /> | ||
</PageHeader> | ||
|
||
<GeneratedPropTable generatedDocGen={generatedDocGen} /> | ||
|
||
<AccessibilitySection | ||
description="IconCompacts are a great way to help users who have difficulties with reading, focus attention, and low vision impairments." | ||
name={generatedDocGen?.displayName} | ||
> | ||
<MainSection.Subsection | ||
columns={2} | ||
description={` | ||
If the icon appears without text, the IconCompact requires \`accessibilityLabel\`, a text description for screen readers to announce and communicate the represented the icon, as shown in the first example. | ||
Avoid using the generic words like "image" or "icon"; instead, use verbs that describe the meaning of the icon. | ||
If an icon has a visible label that describes what the icon represents, \`accessibilityLabel\` can be an empty string. | ||
`} | ||
title="ARIA attributes" | ||
/> | ||
<MainSection.Subsection | ||
description="Ensure that icons use a contrast ratio of 4.5:1 between icon color and background color." | ||
title="Legibility" | ||
/> | ||
</AccessibilitySection> | ||
|
||
<LocalizationSection name={generatedDocGen?.displayName} noDefaultLabelProvider /> | ||
|
||
<MainSection name="Variants"> | ||
<MainSection.Subsection | ||
description={` | ||
IconCompacts can be created using the following color options. \`brandPrimary\` should only be used to represent the Pinterest logo, as it is not accessible. See the [design tokens](/foundations/design_tokens/overview#Text-color) for more info.`} | ||
title="Colors" | ||
> | ||
<CombinationNew | ||
// @ts-expect-error - TS2322 - Type '{ children: ({ color }: { [key: string]: any; }) => Element; color: string[]; }' is not assignable to type 'IntrinsicAttributes & Props'. | ||
color={[ | ||
'default', | ||
'disabled', | ||
'subtle', | ||
'success', | ||
'error', | ||
'warning', | ||
'info', | ||
'recommendation', | ||
'inverse', | ||
'shopping', | ||
'brandPrimary', | ||
'light', | ||
'dark', | ||
]} | ||
> | ||
{({ color }) => <IconCompact accessibilityLabel="" color={color} icon="compact-add" />} | ||
</CombinationNew> | ||
</MainSection.Subsection> | ||
|
||
<MainSection.Subsection | ||
columns={2} | ||
description="IconCompact accepts both Gestalt [icons](/foundations/iconography/library#Search-icon-library) and custom icons, as shown in the second example. For custom icons, follow the [iconography and SVG](/foundations/iconography/library#Custom-SVG-icons) guidelines." | ||
title="Custom icon" | ||
> | ||
<MainSection.Card | ||
cardSize="lg" | ||
sandpackExample={ | ||
<SandpackExample code={builtInIcon} name="Built-in icon" previewHeight={HEIGHT} /> | ||
} | ||
title="Built-in icon" | ||
/> | ||
<MainSection.Card | ||
cardSize="lg" | ||
sandpackExample={ | ||
<SandpackExample code={customIcon} name="Custom icon" previewHeight={HEIGHT} /> | ||
} | ||
title="Custom SVG icon" | ||
/> | ||
</MainSection.Subsection> | ||
</MainSection> | ||
<MainSection name="Writing"> | ||
<MainSection.Subsection columns={2}> | ||
<MainSection.Card | ||
cardSize="md" | ||
description={` | ||
Use a descriptive label to describe the IconCompact | ||
- Be succinct. Exclude unnecessary words. | ||
- Be informative and accurate | ||
- Write in the active voice | ||
- Avoid technical jargon | ||
`} | ||
type="do" | ||
/> | ||
<MainSection.Card | ||
cardSize="md" | ||
description={` | ||
- Use the words "image" or "icon" in the description label; instead, use words that indicate the purpose of the icon. | ||
`} | ||
type="don't" | ||
/> | ||
</MainSection.Subsection> | ||
</MainSection> | ||
|
||
<QualityChecklist component={generatedDocGen?.displayName} /> | ||
|
||
<MainSection name="Related"> | ||
<MainSection.Subsection | ||
description={` | ||
**[IconButton](/web/iconbutton)** | ||
Use IconButton when only an icon is needed to represent an action instead of text. | ||
**[Button](/web/button)** | ||
Use Button to allow users to take an action. | ||
`} | ||
/> | ||
</MainSection> | ||
</Page> | ||
); | ||
} | ||
|
||
export async function getServerSideProps(): Promise<{ | ||
props: { | ||
generatedDocGen: DocGen; | ||
}; | ||
}> { | ||
const generatedDocGen = await docGen('IconCompact'); | ||
const overriddenDocGen = overrideTypes(generatedDocGen, { | ||
icon: (IconCompact?.icons ?? []).map((icon) => `'${icon}'`).join(' | '), | ||
}); | ||
|
||
return { | ||
props: { generatedDocGen: overriddenDocGen }, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { test } from '@playwright/test'; | ||
import expectAccessiblePage from './expectAccessiblePage'; | ||
|
||
test('IconCompact Accessibility check', async ({ page }) => { | ||
await page.goto('/web/iconcompact'); | ||
// @ts-expect-error - TS2345 - Argument of type '{ page: Page; }' is not assignable to parameter of type '{ page: any; rules: any; }'. | ||
await expectAccessiblePage({ page }); | ||
}); |
Binary file modified
BIN
+27.5 KB
(110%)
...visual-test/Icon-list-dark.spec.ts-snapshots/Icon-list-dark-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+29.6 KB
(110%)
...ght/visual-test/Icon-list-vr.spec.ts-snapshots/Icon-list-vr-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+27.4 KB
(110%)
playwright/visual-test/Icon-list.spec.ts-snapshots/Icon-list-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('IconCompact list dark mode visual regression check', async ({ page }) => { | ||
await page.goto('/visual-test/IconCompact-list-dark'); | ||
const locator = page.locator('[data-test-id="visual-test"]'); | ||
await expect(locator).toHaveScreenshot('IconCompact-list-dark.png'); | ||
}); |
Binary file added
BIN
+36 KB
...onCompact-list-dark.spec.ts-snapshots/IconCompact-list-dark-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('IconCompact list visual regression check', async ({ page }) => { | ||
await page.goto('/visual-test/IconCompact-list-vr'); | ||
const locator = page.locator('[data-test-id="visual-test"]'); | ||
await expect(locator).toHaveScreenshot('IconCompact-list-vr.png'); | ||
}); |
Binary file added
BIN
+36.1 KB
...t/IconCompact-list-vr.spec.ts-snapshots/IconCompact-list-vr-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.