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

Add component level theming #11691

Merged
merged 26 commits into from
Mar 25, 2024
Merged

Add component level theming #11691

merged 26 commits into from
Mar 25, 2024

Conversation

aaronccasanova
Copy link
Member

@aaronccasanova aaronccasanova commented Mar 5, 2024

Part of this issue

  • Removed html from theme classes to remove global theme constraint
  • Added ThemeProvider component
  • Updated useTheme to be context aware of parent themes
  • Updated Portal component to be context aware of parent themes
  • Initialized a dark-experimental theme

Example

function App() {
  return (
    /** Sets the default theme globally on the root HTML element (optional) */
    <AppProvider theme="light">
        {/* Sets the dark theme on an internal container element */}
        <ThemeProvider theme="dark-experimental">
          {/* ... */}
        </ThemeProvider>
    </AppProvider>
  )
}

Tophat

Note: In web we will be restricting imports of the ThemeProvider to only areas that Polaris approves

Make sure everything looks the same on spin. The p-theme-light class should be added to the top html element

https://admin.web.web-xubz.sophie-schneider.us.spin.dev/store/shop1

@aaronccasanova
Copy link
Member Author

/snapit

Copy link
Contributor

github-actions bot commented Mar 5, 2024

🫰✨ Thanks @aaronccasanova! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@aaronccasanova
Copy link
Member Author

/snapit

Copy link
Contributor

github-actions bot commented Mar 5, 2024

🫰✨ Thanks @aaronccasanova! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@aaronccasanova
Copy link
Member Author

/snapit

Copy link
Contributor

github-actions bot commented Mar 6, 2024

🫰✨ Thanks @aaronccasanova! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sophschneider sophschneider added the #gsd:38420 Top bar and global reframe project label Mar 8, 2024
@aaronccasanova
Copy link
Member Author

/snapit

Copy link
Contributor

github-actions bot commented Mar 8, 2024

🫰✨ Thanks @aaronccasanova! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sophschneider sophschneider force-pushed the component-level-theming branch from 2fb8dcc to 9b4d070 Compare March 21, 2024 17:39
@sophschneider
Copy link
Contributor

/snapit

Copy link
Contributor

🫰✨ Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sophschneider sophschneider force-pushed the component-level-theming branch 2 times, most recently from c80a43b to d727992 Compare March 22, 2024 20:27
@sophschneider sophschneider changed the title Explore component level theming Add component level theming Mar 22, 2024
@sophschneider
Copy link
Contributor

/snapit

Copy link
Contributor

🫰✨ Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sophschneider
Copy link
Contributor

/snapit

Copy link
Contributor

🫰✨ Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sophschneider sophschneider force-pushed the component-level-theming branch from 2d4c209 to 5430450 Compare March 25, 2024 13:48
@sophschneider sophschneider marked this pull request as ready for review March 25, 2024 14:03
Copy link
Member

@sam-b-rose sam-b-rose left a comment

Choose a reason for hiding this comment

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

Awesome work! This looks great 👍

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

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

Looks good! Welcome back, ThemeProvider

type ThemeNameLocal = typeof themeNamesLocal[number];

export const isThemeNameLocal = (name: string): name is ThemeNameLocal =>
themeNamesLocal.includes(name as any);
Copy link
Member

Choose a reason for hiding this comment

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

Weird typing going on here. Is this temporary until we can use satisfies?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will get lightly cleaned up with the addition of satisfies but the underlying type guard setup would remain the same. This util allows us to narrow any string before passing it to the ThemeProvider (i.e. in Portal) and used to apply runtime adherence of this design decision

@sophschneider sophschneider force-pushed the component-level-theming branch from 4065232 to f07e31e Compare March 25, 2024 18:18
@sophschneider sophschneider merged commit 1e613de into main Mar 25, 2024
14 checks passed
@sophschneider sophschneider deleted the component-level-theming branch March 25, 2024 21:20
sophschneider pushed a commit that referenced this pull request Mar 26, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @shopify/[email protected]

### Minor Changes

- [#11778](#11778)
[`d689bd8f4`](d689bd8)
Thanks [@heyjoethomas](https://github.com/heyjoethomas)! - Added
`PersonSegment` icon

## @shopify/[email protected]

### Minor Changes

- [#11764](#11764)
[`880f31b44`](880f31b)
Thanks [@itwasmattgregg](https://github.com/itwasmattgregg)! - Added
align property for FooterHelp


- [#11691](#11691)
[`1e613de8b`](1e613de)
Thanks [@aaronccasanova](https://github.com/aaronccasanova)! - - Added
`ThemeProvider` component
- Removed `html` from theme classes to remove global theme constraint
    -   Updated `useTheme` to be context aware of parent themes
    -   Updated `Portal` component to be context aware of parent themes
    -   Initialized a `dark-experimental` theme


- [#11787](#11787)
[`c3aefafe2`](c3aefaf)
Thanks [@chloerice](https://github.com/chloerice)! - Added support for
destructive `promotodBulkActions` to `BulkActions`

### Patch Changes

- Updated dependencies
\[[`1e613de8b`](1e613de),
[`d689bd8f4`](d689bd8)]:
    -   @shopify/[email protected]
    -   @shopify/[email protected]

## @shopify/[email protected]

### Minor Changes

- [#11691](#11691)
[`1e613de8b`](1e613de)
Thanks [@aaronccasanova](https://github.com/aaronccasanova)! - - Added
`ThemeProvider` component
- Removed `html` from theme classes to remove global theme constraint
    -   Updated `useTheme` to be context aware of parent themes
    -   Updated `Portal` component to be context aware of parent themes
    -   Initialized a `dark-experimental` theme

## @shopify/[email protected]

### Patch Changes

- Updated dependencies
\[[`1e613de8b`](1e613de)]:
    -   @shopify/[email protected]
    -   @shopify/[email protected]

## @shopify/[email protected]

### Patch Changes

- Updated dependencies
\[[`1e613de8b`](1e613de)]:
    -   @shopify/[email protected]

## [email protected]

### Patch Changes

- Updated dependencies
\[[`1e613de8b`](1e613de)]:
    -   @shopify/[email protected]

## [email protected]

### Patch Changes

- [#11776](#11776)
[`ca8eb99ea`](ca8eb99)
Thanks [@sarahill](https://github.com/sarahill)! - Updated common action
patterns example

- Updated dependencies
\[[`880f31b44`](880f31b),
[`1e613de8b`](1e613de),
[`d689bd8f4`](d689bd8),
[`c3aefafe2`](c3aefaf)]:
    -   @shopify/[email protected]
    -   @shopify/[email protected]
    -   @shopify/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AnnaCheba pushed a commit to AnnaCheba/polaris that referenced this pull request Apr 22, 2024
Part of [this
issue](Shopify/polaris-internal#1513)

- Removed `html` from theme classes to remove global theme constraint
- Added `ThemeProvider` component
- Updated `useTheme` to be context aware of parent themes
- Updated `Portal` component to be context aware of parent themes
- Initialized a `dark-experimental` theme

Example
```tsx
function App() {
  return (
    /** Sets the default theme globally on the root HTML element (optional) */
    <AppProvider theme="light">
        {/* Sets the dark theme on an internal container element */}
        <ThemeProvider theme="dark-experimental">
          {/* ... */}
        </ThemeProvider>
    </AppProvider>
  )
}
```

## Tophat

Note: In web we will be restricting imports of the `ThemeProvider` to
only areas that Polaris approves

Make sure everything looks the same on spin. The `p-theme-light` class
should be added to the top html element

https://admin.web.web-xubz.sophie-schneider.us.spin.dev/store/shop1

---------

Co-authored-by: Sophie Schneider <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#gsd:38420 Top bar and global reframe project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants