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

SearchGuide: Fixes and docs improvements #3801

Merged
Merged
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
116 changes: 75 additions & 41 deletions docs/examples/searchguide/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,106 @@
import { Avatar, AvatarGroup, Flex, Icon, Image, SearchGuide } from 'gestalt';
import { useRef, useState } from 'react';
import { Avatar, Box, Flex, Popover, SearchGuide } from 'gestalt';

export default function Example() {
const enioRef = useRef(null);
const keerthiRef = useRef(null);
const [showEnio, setShowEnio] = useState(false);
const [showKeerthi, setShowKeerthi] = useState(false);

return (
<Flex
alignItems="center"
direction="column"
direction="row"
gap={4}
height="100%"
justifyContent="center"
width="100%"
>
<SearchGuide
accessibilityLabel="Image"
color="01"
text="Image"
accessibilityLabel="Fatima"
color="02"
text="Fatima"
thumbnail={{
image: (
<Image
alt="Image"
naturalHeight={1}
naturalWidth={1}
src="https://i.ibb.co/bBXC23j/fashion.jpg"
avatar: (
<Avatar
name="Fatima"
src="https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg"
/>
),
}}
/>
<SearchGuide
accessibilityLabel="Icon"
color="02"
text="Icon"
thumbnail={{
icon: <Icon accessibilityLabel="" icon="sparkle" />,
}}
/>
<SearchGuide
accessibilityLabel="Avatar"
ref={enioRef}
accessibilityControls="popover"
accessibilityExpanded={showEnio}
accessibilityHaspopup
accessibilityLabel="Sora"
color="03"
text="Avatar"
expandable
onClick={() => setShowEnio((showing) => !showing)}
selected={showEnio}
text="Sora"
thumbnail={{
avatar: <Avatar name="Keerthi" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />,
avatar: (
<Avatar
name="Sora"
src="https://i.pinimg.com/originals/ab/c5/4a/abc54abd85df131e90ca6b372368b738.jpg"
/>
),
}}
/>
{showEnio && (
<Popover
anchor={enioRef.current}
id="popover"
idealDirection="down"
onDismiss={() => setShowEnio(false)}
size="flexible"
>
<Box height={120} overflow="scrollX" padding={4}>
<Flex direction="row" gap={2} wrap>
<SearchGuide color="01" text="Boards" />
<SearchGuide color="02" text="Pins" />
</Flex>
</Box>
</Popover>
)}
<SearchGuide
accessibilityLabel="AvatarGroup"
ref={keerthiRef}
accessibilityControls="popover"
accessibilityExpanded={showKeerthi}
accessibilityHaspopup
accessibilityLabel="Ayesha"
color="04"
text="AvatarGroup"
expandable
onClick={() => setShowKeerthi((showing) => !showing)}
selected={showKeerthi}
text=""
thumbnail={{
avatarGroup: (
<AvatarGroup
accessibilityLabel="Collaborators: Keerthi, Alberto, Enio."
collaborators={[
{
name: 'Keerthi',
src: 'https://i.ibb.co/ZfCZrY8/keerthi.jpg',
},
{
name: 'Alberto',
src: 'https://i.ibb.co/NsK2w5y/Alberto.jpg',
},
{
name: 'Enio',
},
]}
size="md"
avatar: (
<Avatar
name="Ayesha"
src="https://i.pinimg.com/originals/c5/5c/ac/c55caca43a7c16766215ec165b649c1c.jpg"
/>
),
}}
/>
{showKeerthi && (
<Popover
anchor={keerthiRef.current}
id="popover"
idealDirection="down"
onDismiss={() => setShowKeerthi(false)}
size="flexible"
>
<Box height={120} overflow="scrollX" padding={4}>
<Flex direction="row" gap={2} wrap>
<SearchGuide color="01" text="Boards" />
<SearchGuide color="02" text="Pins" />
</Flex>
</Box>
</Popover>
)}
</Flex>
);
}
139 changes: 139 additions & 0 deletions docs/examples/searchguide/avatargroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { Fragment, useRef, useState } from 'react';
import { AvatarGroup, Box, Flex, Popover, SearchGuide } from 'gestalt';

export default function Example() {
const pinsRef = useRef(null);
const creatorsRef = useRef(null);
const [showPins, setShowPins] = useState(false);
const [showCreators, setShowCreators] = useState(false);

return (
<Fragment>
<Flex
alignItems="center"
direction="row"
gap={4}
height="100%"
justifyContent="center"
width="100%"
>
<SearchGuide
ref={pinsRef}
accessibilityControls="popover"
accessibilityExpanded={showPins}
accessibilityHaspopup
accessibilityLabel="Pins"
color="01"
expandable
onClick={() => setShowPins((showing) => !showing)}
selected={showPins}
text="Pins"
thumbnail={{
avatarGroup: (
<AvatarGroup
accessibilityLabel="Pins: Fatima, Sora."
collaborators={[
{
name: 'Fatima',
src: 'https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg',
},
{
name: 'Sora',
src: 'https://i.pinimg.com/originals/ab/c5/4a/abc54abd85df131e90ca6b372368b738.jpg',
},
]}
size="md"
/>
),
}}
/>
<SearchGuide
accessibilityLabel="Boards"
color="04"
text="Boards"
thumbnail={{
avatarGroup: (
<AvatarGroup
accessibilityLabel="Boards: Alberto, Enio."
collaborators={[
{
name: 'Alberto',
src: 'https://i.ibb.co/NsK2w5y/Alberto.jpg',
},
{
name: 'Enio',
src: 'https://i.ibb.co/r7hRdgc/1727060847006.jpg',
},
]}
size="md"
/>
),
}}
/>

<SearchGuide
ref={creatorsRef}
accessibilityControls="popover"
accessibilityExpanded={showCreators}
accessibilityHaspopup
accessibilityLabel="Creators"
color="05"
expandable
onClick={() => setShowCreators((showing) => !showing)}
selected={showCreators}
text="Creators"
thumbnail={{
avatarGroup: (
<AvatarGroup
accessibilityLabel="Creators: Ayesha, Shanice."
collaborators={[
{
name: 'Ayesha',
src: 'https://i.pinimg.com/originals/c5/5c/ac/c55caca43a7c16766215ec165b649c1c.jpg',
},
{
name: 'Mami Wata',
src: 'https://i.pinimg.com/564x/52/ed/6a/52ed6a9475eeb7e0133fb6d3a8b6aaa4.jpg',
},
]}
size="md"
/>
),
}}
/>
</Flex>
{showPins && (
<Popover
anchor={pinsRef.current}
id="popover"
idealDirection="down"
onDismiss={() => setShowPins(false)}
size="flexible"
>
<Box height={120} overflow="scrollX" padding={4}>
<Flex direction="row" gap={2} wrap>
<SearchGuide color="01" text="Boards" />
<SearchGuide color="02" text="Pins" />
</Flex>
</Box>
</Popover>
)}
{showCreators && (
<Popover
anchor={creatorsRef.current}
id="popover"
idealDirection="down"
onDismiss={() => setShowCreators(false)}
size="flexible"
>
<Box height={120} overflow="scrollX" padding={4}>
<Flex direction="row" gap={2} wrap>
<SearchGuide color="01" text="Boards" />
<SearchGuide color="02" text="Pins" />
</Flex>
</Box>
</Popover>
)}
</Fragment>
);
}
7 changes: 5 additions & 2 deletions docs/examples/searchguide/expandable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ export default function Example() {
return (
<Fragment>
<Flex alignContent="stretch" alignItems="center" gap={2} justifyContent="center" width="100%">
<SearchGuide color="01" text="Designs" />
<SearchGuide
// @ts-expect-error - TS2322 - Type 'MutableRefObject<HTMLElement | null>' is not assignable to type 'LegacyRef<HTMLButtonElement> | undefined'.
ref={anchorRef}
accessibilityControls="popover"
accessibilityExpanded={showOutfits}
accessibilityHaspopup
accessibilityLabel="Outfits"
color="02"
expandable
onClick={() => setShowOutfits((showing) => !showing)}
selected={showOutfits}
text="Outfits"
/>
<SearchGuide color="03" text="Vintage" />
</Flex>
{showOutfits && (
<Popover
anchor={anchorRef.current}
id="popover"
idealDirection="down"
onDismiss={() => setShowOutfits(false)}
size="flexible"
Expand Down
Loading
Loading