Skip to content

Commit

Permalink
[Choice] Consolidate se23 logic and styles (#10013)
Browse files Browse the repository at this point in the history
<!--
  ☝️How to write a good PR title:
- Prefix it with [ComponentName] (if applicable), for example: [Button]
  - Start with a verb, for example: Add, Delete, Improve, Fix…
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

### WHY are these changes introduced?

Fixes #9928 <!-- link to issue if one exists -->

<!--
  Context about the problem that’s being addressed.
-->

### WHAT is this pull request doing?

<!--
  Summary of the changes committed.

Before / after screenshots are appreciated for UI changes. Make sure to
include alt text that describes the screenshot.

If you include an animated gif showing your change, wrapping it in a
details tag is recommended. Gifs usually autoplay, which can cause
accessibility issues for people reviewing your PR:

    <details>
      <summary>Summary of your gif(s)</summary>
      <img src="..." alt="Description of what the gif shows">
    </details>
-->

<!-- ℹ️ Delete the following for small / trivial changes -->

- Consolidate styles in Choice.scss
- Consolidates logic in Choice.tsx

### How to 🎩

* [Branch
Storybook](https://5d559397bae39100201eedc1-ltqoskeqza.chromatic.com/?path=/story/all-components-checkbox--default)
* [Prod
Storybook](https://storybook.polaris.shopify.com/?path=/story/all-components-checkbox--default&globals=polarisSummerEditions2023:true)

### 🎩 checklist

- [ ] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [ ] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [ ] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide
  • Loading branch information
gwyneplaine authored and sophschneider committed Aug 15, 2023
1 parent e238a81 commit 8eb0769
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
37 changes: 8 additions & 29 deletions polaris-react/src/components/Choice/Choice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
);
@include responsive-props('choice', 'fill', '--pc-choice-fill');
display: inline-flex;
align-items: center;
justify-content: flex-start;
cursor: pointer;
padding-block-start: calc(
Expand Down Expand Up @@ -78,10 +79,6 @@
var(--pc-choice-bleed-block-start, var(--pc-choice-space-0)) +
var(--pc-choice-bleed-block-end, var(--pc-choice-space-0))
);

#{$se23} & {
align-items: center;
}
}

.labelHidden {
Expand Down Expand Up @@ -120,28 +117,18 @@
}

.disabled + .Descriptions {
#{$se23} & {
// the <Text/> component in the HelpText markup in Choice.tsx is set to `undefined` when the disabled prop is true
// Which tells it to inherit whatever color we specify here.
color: var(--p-color-text-disabled);
}
// the <Text/> component in the HelpText markup in Choice.tsx is set to `undefined` when the disabled prop is true
// Which tells it to inherit whatever color we specify here.
color: var(--p-color-text-disabled);
}

.Control {
// stylelint-disable-next-line -- Polaris component custom properties
--pc-choice-size: 20px;
#{$se23} & {
// stylelint-disable-next-line -- PSE23 temporary property overrides
--pc-choice-size: 18px;
}
--pc-choice-size: 18px;

@media #{$p-breakpoints-md-down} {
// stylelint-disable-next-line -- Polaris component custom properties
--pc-choice-size: 22px;
#{$se23} & {
// stylelint-disable-next-line -- PSE23 Polaris component custom properties
--pc-choice-size: 20px;
}
--pc-choice-size: 20px;
}
display: flex;
flex: 0 0 auto;
Expand All @@ -167,19 +154,11 @@

.Descriptions {
// stylelint-disable-next-line -- Polaris component custom properties
--pc-choice-size: 20px;
#{$se23} & {
// stylelint-disable-next-line -- PSE23 Polaris component custom properties
--pc-choice-size: 18px;
}
--pc-choice-size: 18px;

@media #{$p-breakpoints-md-down} {
// stylelint-disable-next-line -- Polaris component custom properties
--pc-choice-size: 22px;
#{$se23} {
// stylelint-disable-next-line -- PSE23 Polaris component custom properties
--pc-choice-size: 20px;
}
--pc-choice-size: 20px;
}
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
padding-left: calc(var(--p-space-2) + var(--pc-choice-size));
Expand Down
4 changes: 1 addition & 3 deletions polaris-react/src/components/Choice/Choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {ResponsiveProp} from '../../utilities/css';
import type {Error} from '../../types';
import {InlineError} from '../InlineError';
import {Text} from '../Text';
import {useFeatures} from '../../utilities/features';

import styles from './Choice.scss';

Expand Down Expand Up @@ -90,7 +89,6 @@ export function Choice({
bleedInlineStart,
bleedInlineEnd,
}: ChoiceProps) {
const {polarisSummerEditions2023} = useFeatures();
const className = classNames(
styles.Choice,
labelHidden && styles.labelHidden,
Expand Down Expand Up @@ -158,7 +156,7 @@ export function Choice({
as="span"
// `undefined` means color: inherit
// the nearest ancestor with a specified color is .Descriptions in Choice.scss
color={disabled && polarisSummerEditions2023 ? undefined : 'subdued'}
color={disabled ? undefined : 'subdued'}
>
{helpText}
</Text>
Expand Down
5 changes: 0 additions & 5 deletions polaris-react/src/components/ResourceItem/ResourceItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@
height: 100%;
}

.CheckboxLabel {
// Pass-through the item alignment to the underlaying label
align-items: inherit;
}

// stylelint-disable-next-line selector-max-class -- generated by polaris-migrator DO NOT COPY
.focusedInner,
.focusedInner.focused,
Expand Down

0 comments on commit 8eb0769

Please sign in to comment.