Skip to content

Commit

Permalink
Revert "[Listbox, OptionList] Right align check icons on selected lis…
Browse files Browse the repository at this point in the history
…t items" (Shopify#11838)

Reverts Shopify#11697

Need to better accommodate custom elements within list items
  • Loading branch information
kyledurand authored Apr 4, 2024
1 parent d5cb5ea commit f7f3718
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 44 deletions.
5 changes: 0 additions & 5 deletions .changeset/chatty-timers-marry.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/strong-otters-fetch.md

This file was deleted.

7 changes: 5 additions & 2 deletions polaris-react/src/components/Listbox/Listbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ export function WithAction() {
<Listbox.Option value="UniqueValue-2" divider>
Item 2
</Listbox.Option>
<Listbox.Action value="ActionValue" icon={PlusCircleIcon}>
Add item
<Listbox.Action value="ActionValue">
<LegacyStack spacing="tight">
<Icon source={PlusCircleIcon} tone="base" />
<div>Add item</div>
</LegacyStack>
</Listbox.Action>
</Listbox>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
.ActionDivider {
margin-bottom: var(--p-space-100);
}

.Icon {
padding-right: var(--p-space-200);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,17 @@ export const TextOption = memo(function TextOption({
isAction && styles.isAction,
);

const placeholder = isAction ? null : <Box width="20px" />;

const optionMarkup = (
const optionMarkup = selected ? (
<Box width="100%">
<InlineStack wrap={false} gap="100">
{selected ? (
<span>
<Icon source={CheckIcon} />
</span>
) : (
placeholder
)}
<InlineStack wrap={false} align="space-between" gap="200">
{children}
<InlineStack align="end">
<Icon source={CheckIcon} />
</InlineStack>
</InlineStack>
</Box>
) : (
<>{children}</>
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

display: flex;
flex-wrap: nowrap;
gap: var(--p-space-100);
justify-content: space-between;

/* stylelint-disable-next-line selector-max-specificity -- required for focus-visible support */
&.focused:focus-visible:not(:active) {
Expand Down Expand Up @@ -134,6 +134,14 @@
align-items: flex-end;
}

.Icon {
margin-left: var(--p-space-200);

svg {
fill: var(--p-color-icon-brand);
}
}

.Checkbox {
box-sizing: border-box;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {classNames, variationName} from '../../../../utilities/css';
import type {InlineStackProps} from '../../../InlineStack';
import {InlineStack} from '../../../InlineStack';
import {Checkbox as PolarisCheckbox} from '../../../Checkbox';
import {Box} from '../../../Box';

import styles from './Option.module.css';

Expand Down Expand Up @@ -126,27 +125,20 @@ export function Option({
onBlur={toggleFocused}
aria-pressed={active || select}
>
{select || active ? (
<span className={styles.Icon}>
<Icon source={CheckIcon} tone="base" />
</span>
) : (
<Box width="20px" />
)}
<InlineStack
wrap={false}
blockAlign={verticalAlignToBlockAlign(verticalAlign)}
>
{mediaMarkup}
<span
style={{
minWidth:
typeof label === 'string' ? `${label.length}ch` : 'initial',
}}
<>
<InlineStack
wrap={false}
blockAlign={verticalAlignToBlockAlign(verticalAlign)}
>
{mediaMarkup}
{label}
</span>
</InlineStack>
</InlineStack>
{(select || active) && (
<span className={styles.Icon}>
<Icon source={CheckIcon} />
</span>
)}
</>
</button>
);

Expand Down

0 comments on commit f7f3718

Please sign in to comment.