-
Notifications
You must be signed in to change notification settings - Fork 33
feat(@deephaven/components): DH-14630 Custom React Spectrum Provider #1211
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
Merged
bmingles
merged 13 commits into
deephaven:main
from
bmingles:1210-react-spectrum-provider
Apr 18, 2023
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d2c8b02
Custom SpectrumProvider component
bmingles c31c3b4
latest package lock
bmingles f704370
Refactored custom Spectrum theming
bmingles c9bcbc1
Added some comments
bmingles 05a9c02
Added theme comment
bmingles 94afdf3
Split out Spectrum custom theme into a util module
bmingles 67e374c
Unit tests for SpectrumUtils
bmingles 52b81b0
SpectrumProvider unit tests
bmingles 24d1894
Moved Spectrum theme modules
bmingles 7da9471
Fixed import path and updated comment
bmingles 063530d
Removed custom SpectrumProvider
bmingles 2f3cb77
Installed @react-spectrum/theme-default
bmingles 45ab830
Latest package-lock
bmingles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| module.exports = { | ||
| 'dh-spectrum-theme--dark': 'mock.dark', | ||
| }; |
This file contains hidden or 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,3 @@ | ||
| module.exports = { | ||
| 'dh-spectrum-theme--light': 'mock.light', | ||
| }; |
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
| /// Utilty for increasing specificity by repeating a given selector n number of | ||
| /// times. | ||
| /// | ||
| /// It should work for selectors that can be concatenated without delimiters | ||
| /// such as '.some-selector.some-selector', '#some-id#some-id', or '&&'. A | ||
| /// case where it would not work would be with an element selector e.g. 'divdiv'. | ||
| /// | ||
| /// Example usage: | ||
| /// | ||
| /// #{multiply-specificity-n('.some-selector', 2)} { | ||
| /// } | ||
| /// | ||
| /// would produce | ||
| /// | ||
| /// .some-selector.some-selector { | ||
| /// } | ||
| /// | ||
| /// @param {string} $selector the selector to duplicate | ||
| /// @param {number} $n number of times to duplicate | ||
| /// @return {string} duplicated selector | ||
| @function multiply-specificity-n($selector, $n) { | ||
| $result: $selector; | ||
| @for $i from 2 through $n { | ||
| $result: selector-append($result, $selector); | ||
| } | ||
|
|
||
| @return $result; | ||
| } |
This file contains hidden or 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,12 @@ | ||
| /** | ||
| This module contains overrides of React Spectrum css variables for the default | ||
| `dark` Deephaven theme. | ||
| */ | ||
| @use '../scss/bootstrap_overrides' as bootstrap; | ||
| @use '../scss/util' as *; | ||
|
|
||
| // Doubling specificity to ensure this takes precedence over default Spectrum | ||
| // styles. | ||
| #{multiply-specificity-n('.dh-spectrum-theme--dark', 2)} { | ||
| --spectrum-alias-background-color-default: #{bootstrap.$interfaceblack}; | ||
| } |
This file contains hidden or 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,12 @@ | ||
| /** | ||
| This module contains overrides of React Spectrum css variables for the default | ||
| `light` Deephaven theme. | ||
| */ | ||
| @use '../scss/bootstrap_overrides' as bootstrap; | ||
| @use '../scss/util' as *; | ||
|
|
||
| // Doubling specificity to ensure this takes precedence over default Spectrum | ||
| // styles. | ||
| #{multiply-specificity-n('.dh-spectrum-theme--light', 2)} { | ||
| --spectrum-alias-background-color-default: #{bootstrap.$interfacewhite}; | ||
| } |
This file contains hidden or 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,22 @@ | ||
| import { defaultTheme } from '@adobe/react-spectrum'; | ||
| import { themeDHDefault } from './SpectrumUtils'; | ||
|
|
||
| describe('themeDHDefault', () => { | ||
| it('should merge Spectrum default with DH custom styles', () => { | ||
| const { global, light, dark, medium, large } = defaultTheme; | ||
|
|
||
| expect(themeDHDefault).toEqual({ | ||
| global, | ||
| light: { | ||
| ...light, | ||
| 'dh-spectrum-theme--light': 'mock.light', | ||
|
bmingles marked this conversation as resolved.
|
||
| }, | ||
| dark: { | ||
| ...dark, | ||
| 'dh-spectrum-theme--dark': 'mock.dark', | ||
| }, | ||
| medium, | ||
| large, | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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,54 @@ | ||
| import { defaultTheme } from '@adobe/react-spectrum'; | ||
|
bmingles marked this conversation as resolved.
Outdated
|
||
| import darkDH from './SpectrumThemeDark.module.scss'; | ||
| import lightDH from './SpectrumThemeLight.module.scss'; | ||
|
|
||
| const { global, light, dark, medium, large } = defaultTheme; | ||
|
|
||
| /** | ||
| * Extend light + dark theme variables with DH defaults. | ||
| * | ||
| * A theme is just a mapped collection of css class names that are generated | ||
| * from a collection of css modules. | ||
| * | ||
| * e.g. | ||
| * { | ||
| * global: { | ||
| * spectrum: 'spectrum_9e130c', | ||
| * 'spectrum--medium': 'spectrum--medium_9e130c', | ||
| * 'spectrum--large': 'spectrum--large_9e130c', | ||
| * 'spectrum--darkest': 'spectrum--darkest_9e130c', | ||
| * 'spectrum--dark': 'spectrum--dark_9e130c', | ||
| * 'spectrum--light': 'spectrum--light_9e130c', | ||
| * 'spectrum--lightest': 'spectrum--lightest_9e130c', | ||
| * }, | ||
| * light: { | ||
| * 'spectrum--light': 'spectrum--light_a40724', | ||
| * 'dh-spectrum-theme--light': '_dh-spectrum-theme--light_1hblg_22', | ||
| * }, | ||
| * dark: { | ||
| * 'spectrum--darkest': 'spectrum--darkest_256eeb', | ||
| * 'dh-spectrum-theme--dark': '_dh-spectrum-theme--dark_f7kge_22', | ||
| * }, | ||
| * medium: { | ||
| * 'spectrum--medium': 'spectrum--medium_4b172c', | ||
| * }, | ||
| * large: { | ||
| * 'spectrum--large': 'spectrum--large_c40598', | ||
| * }, | ||
| * } | ||
| */ | ||
| /* eslint-disable import/prefer-default-export */ | ||
| export const themeDHDefault = { | ||
| global, | ||
| light: { | ||
| ...light, | ||
| ...lightDH, | ||
| }, | ||
|
bmingles marked this conversation as resolved.
|
||
| dark: { | ||
| ...dark, | ||
| ...darkDH, | ||
| }, | ||
| // scales | ||
| medium, | ||
| large, | ||
| }; | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.