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

Styled components v6 support #7165

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Styled components v6 support #7165

wants to merge 16 commits into from

Conversation

jcfilben
Copy link
Collaborator

What does this PR do?

Where should the reviewer start?

What testing has been done on this PR?

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Should this PR be mentioned in the release notes?

Is this change backwards compatible or is it a breaking change?

jcfilben and others added 11 commits October 23, 2023 15:26
* Initial setup for styled components config approach

* Add config to styled components

* update snapshots

* change additional component to use styled box instead of as={box}

* RadioButton, CheckBox, and RangeInput fixes

* Filter out kind from button and elevation from layer

* adjust package.json to support styled components 5 or 6

* increase bundlesize

* remove stylis from peerDependencies

* remove stylis dependency

* enable vendor prefixes

* added grommet wrapper to tests

* revert default props test

* move styleSheetManager above themeContext

* remove StyleSheetManager from Grommet component

* update snapshots

* update snapshots
* Add comment

* Alter comment
* Add comment 2

* Align config to master
…t to CheckBox (#6999)

* Gets the remove icon from theme (#6960)

* Gets the remove icon from theme

* Update src/js/components/Tag/Tag.js

Co-authored-by: Mike Kingdom <[email protected]>

---------

Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Improve event handler typings for Box (#6983)

Co-authored-by: Jessica Filben <[email protected]>

* Prevent row focus style for unclickable rows with onSelect (#6719) (#6985)

Co-authored-by: Jessica Filben <[email protected]>

* Improve event handler typings for Chart (#6984)

Co-authored-by: Jessica Filben <[email protected]>

* Updated v2.34.0

* add webkit user select to CheckBox

---------

Co-authored-by: Vinod Krishna Vellampalli <[email protected]>
Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: jainex <[email protected]>
Co-authored-by: Michael Huynh <[email protected]>
* minor change to trigger circleci

* add comment to circleci config
* Gets the remove icon from theme (#6960)

* Gets the remove icon from theme

* Update src/js/components/Tag/Tag.js

Co-authored-by: Mike Kingdom <[email protected]>

---------

Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Improve event handler typings for Box (#6983)

Co-authored-by: Jessica Filben <[email protected]>

* Prevent row focus style for unclickable rows with onSelect (#6719) (#6985)

Co-authored-by: Jessica Filben <[email protected]>

* Improve event handler typings for Chart (#6984)

Co-authored-by: Jessica Filben <[email protected]>

* Updated v2.34.0

* upgrade dependencies (#7004)

* Remove unnecessary useEffect (#7011)

* Stop form submit event from bubbling up (#7005)

* Stop form submit event from bubbling up

* Add unit test

* Use fireEvent

* Use formRef to determine submission, let event bubble

* Remove unneccessary .contains

---------

Co-authored-by: Jessica Filben <[email protected]>

* Updated v2.34.1

* Allow caller to specify step for DataFilter range (#6942)

* Allow caller to specify step

* Update PropTypes

* Remove unnecessary snapshot

* Fix sort

* Use variable to be self documenting

---------

Co-authored-by: Jessica Filben <[email protected]>

* Remove suggestion to use UserEvent over FireEvent (#7023)

* Update CONTRIBUTING.md

* Update PULL_REQUEST_TEMPLATE.md

* Update prop types and typescript types (#7028)

* Update DataSummary messages object (#7022)

Co-authored-by: Jessica Filben <[email protected]>

* Align DataFilters layer to Design System best practices (#7021)

* Align DataFilters layer to Design System best practices

* Update snapshots

* Update snapshots

* Update test

* Make DataFilter range inclusive of bounds (#7026)

* Make datafilter range inclusive of bounds

* adjust test with feedback from review

* Enhance Data screen reader announcements and add search debounce (#7010)

* Enhance Data screen reader announcements and add search debounce

* Fix Data tests

* Use fireEvent to fix timeout

* Update src/js/components/Data/Data.js

Co-authored-by: Matthew Glissmann <[email protected]>

* Fix lint error

---------

Co-authored-by: Matthew Glissmann <[email protected]>

* add aria-label for inputs (#7038)

* add aria-label for inputs

* only for no form example

* add updated snapshot

* use undefined instead

* add label to select

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* [Type] remove `onClick` from types of Box props (#7018)

* remove onClick from types of Box props

`onClick` type is inherited generically from IntrinsicElements and grommet is currently limiting the type.

* remove onClick type dependency

---------

Co-authored-by: Jessica Filben <[email protected]>

* upgrade minor dependencies (#7040)

* upgrade major dependencies

* revert testcafe

* remove carrot on typsscript

* remove carrot on testcafe

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Adjust NameValueList to account for xsmall screen size (#7047)

* Adjust NameValueList to account for xsmall screen size

* create isSmall util function

* Fix Select focus when opening drop with search (#6901) (#6982)

* Fix Select focus when opening drop with search (#6901)

* Adjust bundle size for Select focus fix (#6901)

---------

Co-authored-by: Jessica Filben <[email protected]>

* Improve DataFilter and RangeSelector handling of floating point values (#7033)

* Improve DataFilter range default label

* Improve default behavior of DataFilter range label

* When RangeSelector is reset to min/max set value to undefined

* revert changes from previous commit

* Fix floating point calculations

* Remove arbitrary precision, calculate in integer math

* Remove unused function

---------

Co-authored-by: Jessica Filben <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* add check if values are arrays (#7045)

* add check if values are arrays

* Update Form.js

* add taylor suggestions

* fix condition

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Update README.md (#7050)

* Update README.md

Update readme

* Update README.md

* Update README.md

Co-authored-by: Jessica Filben <[email protected]>

* Update README.md

* Update README.md

Co-authored-by: Jessica Filben <[email protected]>

---------

Co-authored-by: Jessica Filben <[email protected]>

* Fixed handling of multi-level property names that are used as RangeSelectors in filters (#7049)

Co-authored-by: Jessica Filben <[email protected]>

* Add DataClearFilters component (#7025)

* Add DataClearFilters component

* Update snapshots

* Rename showClearFilters to clearFilters

* Remove onUpdate from Data, make associated refinements

* Add data.button.kind to theme, remove hard coded kind=toolbar

* Add updateOn change to noForm DataSort, fix test

* Update snapshot

* Remove updateOn on Data from stories

---------

Co-authored-by: Jessica Filben <[email protected]>

* change datafilters default presentation with toolbar prop to layer (#7057)

* add dataFormContext (#7053)

* add dataFormContext

* update test

* Update src/js/components/DataSearch/DataSearch.js

Co-authored-by: Taylor Seamans <[email protected]>

* fix package

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Adjust Data properties to add filter, sort, and search booleans (#7046)

* Adjust Data properties to add filterable, sortable, and searchable

* Based on discussion with dev team removed '-able' suffix from prop names to allow for future enhancements beyond boolean value

* fix bundlesize

* add test for sub objects with rangeselector (#7065)

* add test for sub objects with rangeselector

* Update src/js/components/DataFilters/__tests__/DataFilters-test.tsx

Co-authored-by: Taylor Seamans <[email protected]>

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>
Co-authored-by: Taylor Seamans <[email protected]>

* Fix toolbar story (#7062)

* fix toolbar story

* fix toolbar story

---------

Co-authored-by: Brittany Archibeque <[email protected]>

* Updated v2.34.2

* update dependencies (#7067)

Co-authored-by: Brittany Archibeque <[email protected]>

* Fix images accessibility violations (#7061)

* fix: images accessibility violations

* Update Simple.js

* fix: starRating - typescript issues (#7073)

* fix: starRating - typescript issues

* Update index.d.ts

* Remove use of `hoverIndicator` within Data (#7078)

* Remove use of  within Data

* Resolve snapshots

* SelectMultiple new options on search (#7079)

* SelectMultiple new options on search

* Incorporate feedback from review

* remove story

* update chromatic token (#7086)

* Decouple DataFilters and DataSort, refine toolbar layout (#7080)

* Decouple DataFilters and DataSort, refine toolbar layout

* Make refinements to clear filters, toolbar

* Refine clearFilters logic

---------

Co-authored-by: Jessica Filben <[email protected]>

* Refine DataFilters badge behavior for RangeSelector reset to min/max (#7083)

* Refine DataFilters badge behavior for RangeSelector

* Generalize event name

* Alter approach to be more resilient to changing RangeSelector values

* fix: Resolve hover styling and tooltip issue for DataSort control (#7069)

* fix: Resolve hover styling and tooltip issue for DataSort control

* fix: Resolve hover styling and tooltip issue for DataSort control

* Removed undo changes button from DataForm (#7088)

* remove undo changes button

* remove undo changes button

---------

Co-authored-by: Brittany Archibeque <[email protected]>

* update npm token name (#7087)

* Fix groupHeader theming properties for DataTable (#6925) (#6986)

* Fix groupHeader theming properties for DataTable (#6925)

Had to update all existing DataTable test snapshots that involve the use
of table grouping. They would have been created during states where row
group header theme properties were not being passed through at all.

* Update default groupHeader theme for backward compatibility (#6925)

Test snapshots involving row groups for DataTable needed to be updated
once more to reflect the change in default theme, which should ensure
least surprise to any users of the component.

---------

Co-authored-by: Jessica Filben <[email protected]>

* Set min-width of DataFilters layer (#7094)

Co-authored-by: Jessica Filben <[email protected]>

* DataSearch: Removed dependence on form (#7091)

* Removed dependence on form for DataSearch

* wrap search in a Box for sizing

* Move debounce to utils and clear search on named view

* update Data-test snapshots

* Fixed a dependency cycle

* Clear name view on search change if it has search term

---------

Co-authored-by: Jessica Filben <[email protected]>

* fix: starRating - form value not synched (#7077)

* fix: starRating - form value not synched

* fix: starRating - form value not synched

* add: new test case for start rating default value

* reverted StarRating.js default value state

* DataFilters -- display badge when view applied (#7084)

* Display badge with view

* Incorporate badge configuration

* Removed dependence on form for DataSearch

* Remove unused onTouched

* Fix bug when range selector reset was still contributing to badge count

* Include RangeSelector in clearEmpty logic to standardize when filters are removed from view object

* Flatten to match filter name structure

* Update src/js/components/Data/__tests__/Data-test.tsx

* Update snapshots

* Fix untouched Toolbar snapshot

---------

Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Add jest tests for Data features (#7100)

* Add jest tests for Data features

* Fix test based on latest view badge work

---------

Co-authored-by: Jessica Filben <[email protected]>

* Adjust logic in DataClearFilters story (#7108)

* Fix undefined case for DataFilter (#7111)

* Fix undefined case for DataFilter

* Update src/js/components/DataFilter/DataFilter.js

Co-authored-by: Jessica Filben <[email protected]>

---------

Co-authored-by: Jessica Filben <[email protected]>

* Add test for adding additional options to SelectMultiple within onSearch (#7105)

* Add test for adding additional options to SelectMultiple within onSearch

* change test to use fireEvent instead of userEvent

* move faketimers to additional options onSearch test

* Implement DataSearch updateOn property (#7110)

* Implement DataSearch updateOn property

* Address review feedback

* Address review feedback

* Removed UpdateOnSubmit story from chromatic

* fix missing props and typings for tag component (#7099)

* fix missing props and typings for tag component

* fix missing props and typings for tag component

---------

Co-authored-by: sthpe <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* SelectMultiple i18n enhancements (#7104)

* feat: add internationalization to selectMultiple

* fix: spelling selectedCount

* fix: spelling selectedCount

* feat: update SelectionSummary with PR commetns

* feat: add jest Test for custommessages

* fix: remove messages from Basic Props

* fix: add PR fix

* Feat: add localization to aria text

* feat: fix all PR commetnts

* fix: Test

* fix: update failing test snapshot

* update snapshot

* fix: pr comments & try fixing ci tests

* fix: snapshots

* remove comment

* remove useless $ in locales

* select messages key in alphabetical order

* Removed dependence on form for DataSearch

* selecMultiple.summarizedValue

* selectMultiple.clearAll keys

* selectMultiple.selectAll keys

* selectMultiple.selected key

* selectMultiple.selectedOfTotal key + fix dat-filter test selectAllA11y

* selectMultiple.open key + fix clearAllA11y

* selectMultiple.search key

* SelectMultiple props/locales keys in alphabetical order

* last multiple => summarizedValue

* alphabetical order for selectMultiple proptypes

* Update snapshots

* Small refinements to SelectMultiple i18n work

* Remove unsupported message

* Refine Typescript/propTypes for backwards compatibility

* Update src/js/components/SelectMultiple/index.d.ts

Co-authored-by: Brittany <[email protected]>

* Update src/js/components/SelectMultiple/propTypes.js

* Alphabetize

* selectDropDown --> selectDrop

* Fix snapshots

---------

Co-authored-by: jboeckle <[email protected]>
Co-authored-by: dbo2019 <[email protected]>
Co-authored-by: Thibault Ollivier <[email protected]>
Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: tol-any <[email protected]>
Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: Brittany <[email protected]>

* fix: Remove 'label' attribute from <label> tag (#7101)

* Remove 'label' attribute from <label> tag

* fix: Remove 'label' attribute from <label> tag

* Reverted Simple.js

* Align Data+friends propTypes/index.d.ts to latest behavior (#7116)

* Remove unused Dataform message

* misc cleanups

* Fix

* Add missing messages

* Update src/js/components/Data/index.d.ts

* Fix PropTypes syntax

* Enhance DataSummary with selected messages (#7114)

* Enhance DataSummary with selected messages

* Increase bundlesize

* Add propTypes/index.d.ts

---------

Co-authored-by: Jessica Filben <[email protected]>

* Fix DataTableColumns undefined case (#7117)

* Check properties length before displaying data clear filters button (#7119)

* Updated v2.35.0

* remove stable notification from storybook for data components (#7113)

* remove stable notification from storybook for data components

* Update src/js/components/DataView/stories/Simple.js

Co-authored-by: Jessica Filben <[email protected]>

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* upgrade dependencies (#7124)

Co-authored-by: Brittany Archibeque <[email protected]>

* upgrade remaining dependencies (#7126)

Co-authored-by: Brittany Archibeque <[email protected]>

* Align Data + friends storybook examples with best practices (#7132)

* Align storybook examples with best practices

* Rename composed toolbar file

* Add primaryKey to List theme (#7136)

* fix(range): enables range wheel event override (#7130)

* component(range input): adds wheel override to theme

* Update src/js/components/RangeInput/__tests__/RangeInput-test.tsx

Co-authored-by: Jessica Filben <[email protected]>

* cr: removes unused import

* fix(range): renames theme context variable

* fix(range): address PR feedback

---------

Co-authored-by: Tanner B. Hess Webber <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Form field add max and threshold to validation (#6550)

* feat: first commit

* test: update snapshots

* chore: updata README.md

* chore: code review

* chore: update validate threshold structure

* chore: update story

* test: update snapshot

* feat: add default threshold

* feat: update storybook

* fix: FormField.js

* chore: minor fixes

* chore: change bundle maxSize to 160 kB

* chore: minor changes

* refactor: add format message

* chore: update bundlesize

* style: remove comment line

* feat: update FormField threshold message

* chore: update bundlesize

* chore: fix bundlesize

* feat: last changes

* chore: update bundlesize

* Adjust naming of messages

* refactor: Form Threshold validation

* refactor: minor changes

* increase bundlesize

---------

Co-authored-by: Jessica Filben <[email protected]>
Co-authored-by: Matt Glissmann <[email protected]>
Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Upgrade Node Engine From 16 to 18 (#6937)

* update node engine version

* Updating Engine Version

Co-authored-by: Jessica Filben <[email protected]>

---------

Co-authored-by: Jessica Filben <[email protected]>

* Remove engine-strict: true from package.json (#7141)

* revert node version back to 16 (#7142)

* fix: onOrder buttons should be selectable by hitting the 'Space' key (#7140)

* fix: onOrder buttons should be selectable by hitting the 'Space' key

* ref: added event.preventDefault onSpace

* enhancement : preventDefault added to OnDown and OnUp calls (#7144)

* fix: preventDefault added to OnDown and OnUp calls

* revered changes package.json

* Update package.json

* Run form submit validation when submit is fired directly on input (#7148)

* Run form submit validation when submit is fired directly on input

* Add jest test

* Remove .only

* Add test workflow (#7150)

* Remove chromatic token from package.json (#7151)

* Remove chromatic token from package.json

* Remove test workflow

* Add CircleCI context for release and publish jobs (#7152)

* Enhance Box `gap` to accept object with `row` and `column` (#7147)

* add code to account for row and columngap

* Update src/js/components/Box/__tests__/Box-layout-test.tsx

Co-authored-by: Taylor Seamans <[email protected]>

* Update src/js/components/Box/__tests__/Box-layout-test.tsx

Co-authored-by: Taylor Seamans <[email protected]>

* Update src/js/components/Box/propTypes.js

Co-authored-by: Taylor Seamans <[email protected]>

* Update src/js/components/Box/index.d.ts

Co-authored-by: Taylor Seamans <[email protected]>

* fix feedback

* address feedback

* fix object passing through

* fix if statement

* Update src/js/components/Box/index.d.ts

Co-authored-by: Taylor Seamans <[email protected]>

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* Readonly enhancement for TextInput and DateInput (#7123)

* read only accessibility test

* add readOnly styling and readOnlyCopy prop to DateInput and TextInput

* update bundlesize

* add tests

* Remove icon from TextInput when in readOnly mode and ensure readonly styling is contained to TextInput and DateInput

* incorporate review feedback

* remove unnecessary aria-readonly prop

* feedback from review

* Refine styling and increase button click target

* Fix SelectMultiple snapshosts

* Remove extra readOnly prop

* Fix formfield readOnlyCopy styling

* Update src/js/components/TextInput/TextInput.js

Co-authored-by: Jessica Filben <[email protected]>

---------

Co-authored-by: Taylor Seamans <[email protected]>

* Anchor icon and icon-text has extra space fixed (#6534)

* fix: Anchor icon fixed

* fix: Anchor alignment fixed

* refactor: box property

Added Box styled as InlineBox for Anchro component only.

* refactor: unused snippet removed.

* test: Snapshot updated.

* clean up unnessicary changes

* Update propTypes.js

* Update DropContainer.js

* Update LayerContainer.js

* Update RenderedList.js

* Update Simple.tsx

* Update index.d.ts

* change inline box to icon only

* needs vertical align bottom

* fix: Anchor Icon and its alignment.

* test: Snapshot updated

* refactor: property position updated

* test: Snapshots updated

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Brittany <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* fix: focus indicator for Layer's hidden anchor in Firefox (#7146)

* fix: List focus via keyboard (#7143)

* fix: List focus via keyboard

* test: Update Snapshots

* reafactor: item focus removed

* test: Snapshot updated

---------

Co-authored-by: Brittany <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>

* ensure window is available for when SSR (#7156)

* Fix dropHeight of DataFilter SelectMultiple (#7157)

* List keyboard behavior test and fix lint issues (#7158)

* test list keyboard behavior with space and fix lint issues

* Update src/js/components/List/__tests__/List-test.js

* Pagination — Add `summary` and `stepOptions` (#7133)

* add draft of stepselector

* clean up code

* add summary to one PR

* add default value for when stepselector is boolean

* add feedback set up points for disscussion for demo

* add feedback set up points for disscussion for demo

* take out unneeded comment

* update code based on team feedback

* fix feedback

* Update src/js/languages/default.json

Co-authored-by: Taylor Seamans <[email protected]>

* fix feedback

* update values

* add tests

* change value name

* add gap

* add edgecase for 0 items

* fix namig

* clean up code logic

* Update src/js/components/Pagination/Pagination.js

Co-authored-by: Jessica Filben <[email protected]>

* update tests

* Update src/js/components/Pagination/__tests__/Pagination-test.tsx

Co-authored-by: Jessica Filben <[email protected]>

* Update src/js/components/Pagination/PaginationStep.js

Co-authored-by: Matthew Glissmann <[email protected]>

* add valueLabel

* incorporate Matts feedback

* fix story

* align gap with figma

* Update src/js/components/Pagination/stories/Steps.js

Co-authored-by: Matthew Glissmann <[email protected]>

* update story

* Update src/js/components/Pagination/stories/Steps.js

Co-authored-by: Matthew Glissmann <[email protected]>

* update bundle size

* merge master

---------

Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Jessica Filben <[email protected]>
Co-authored-by: Matthew Glissmann <[email protected]>

* Updated v2.36.0

* test npm token (#7162)

Co-authored-by: Brittany Archibeque <[email protected]>

* update bundlesize

---------

Co-authored-by: Vinod Krishna Vellampalli <[email protected]>
Co-authored-by: Taylor Seamans <[email protected]>
Co-authored-by: Mike Kingdom <[email protected]>
Co-authored-by: jainex <[email protected]>
Co-authored-by: Michael Huynh <[email protected]>
Co-authored-by: Matthew Glissmann <[email protected]>
Co-authored-by: Brittany <[email protected]>
Co-authored-by: Brittany Archibeque <[email protected]>
Co-authored-by: Shimi <[email protected]>
Co-authored-by: Basith <[email protected]>
Co-authored-by: Sulaymon333 <[email protected]>
Co-authored-by: sthpe <[email protected]>
Co-authored-by: jboeckle <[email protected]>
Co-authored-by: dbo2019 <[email protected]>
Co-authored-by: Thibault Ollivier <[email protected]>
Co-authored-by: tol-any <[email protected]>
Co-authored-by: kid-icarus <[email protected]>
Co-authored-by: Tanner B. Hess Webber <[email protected]>
Co-authored-by: Gabriel Quaresma <[email protected]>
Co-authored-by: Joelo <[email protected]>
Co-authored-by: Umesh Verma <[email protected]>
@jcfilben jcfilben marked this pull request as draft March 15, 2024 15:51
@jcfilben jcfilben marked this pull request as ready for review March 18, 2024 15:38
@@ -189,6 +190,9 @@
"statements": 86.6
}
},
"moduleNameMapper": {
"^styled-components": "styled-components/dist/styled-components.browser.cjs.js"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I forget why we needed this -- is it documented anywhere why we have this? Would be helpful to keep note for future reference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe we were having issues with the jest tests, the suggestion to add this line came from styled-components/jest-styled-components#144 (comment)

} from '../../utils';

export const StyledContainer = styled.div`
export const StyledContainer = styled(Box)`
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jcfilben Can you remind me why in some cases we changed to "Box" vs others we kept as div?

would be good to document this decision for future reference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There were some places that were using styled.div and as={Box} so I think we decided to just simplify to styled(Box)

.circleci/config.yml Outdated Show resolved Hide resolved
@britt6612 britt6612 requested a review from taysea March 25, 2024 16:45
},
"dependencies": {
"@emotion/is-prop-valid": "^1.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some rationale for this being a direct dependency rather than a peer dependency? It is unintuitive (to me, at least) that a package used specifically for a peer dependency would be a direct dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jcfilben Do we need to add this directly? Or is it included with styled-components v6?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not included, but it can be configured globally through styled components (and likely will in many cases). The alternative is to migrate to transient props, which a lot of people seem to be balking at

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@emotion/is-prop-valid is a dependency of styled-components but since we need to import and use isPropValid within our own code I added it as a dependency on Grommet. Although it is a styled-components dependency, I didn't see a way to import isPropValid through styled-components

Copy link
Contributor

Choose a reason for hiding this comment

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

v6 dropped the direct dependency, making it a peer dependency. They migrated to transient props instead

https://styled-components.com/docs/faqs#shouldforwardprop-is-no-longer-provided-by-default

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We explored transient props but ultimately decided to use is-prop-valid to filter out styling props from being passed to the dom. Some more context on our explorations:
#6947
#6941
https://github.com/grommet/grommet/tree/styled-components-v6 - branch where we started converting to transient props

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for jogging my memory Jessica!

@@ -51,9 +51,10 @@
"peerDependencies": {
"react": "^16.6.1 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.6.1 || ^17.0.0 || ^18.0.0",
"styled-components": "^5.1.0"
"styled-components": "^5.1.0 || ^6.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Supporting both seems like it might be risky with significant breaking changes specifically because of how v6 handles nesting as compared to v5. You can find that documentation here.

Copy link
Collaborator

@taysea taysea Mar 27, 2024

Choose a reason for hiding this comment

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

Hey @Tbhesswebber thanks for commenting. Could you elaborate on your concerns? Definitely want to hear them out as we're considering adding support for v6 as well.

With these changes, we are taking care of shouldForwardProp (mentioned in your link above) on all styled instances within grommet components (see styles.js under files changed). This will ensure proper styling if someone is using styled components v6.

We previously did an alpha release with the behavior and didn't see any issues. That release was v2.35.0-alpha.1 if it's helpful to have a released version to try. https://github.com/grommet/grommet/releases/tag/v2.35.0-alpha.1

Copy link
Contributor

Choose a reason for hiding this comment

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

I updated the link above (I was hasty with copy pasta, it seems).

const Foo = styled.button`
  :hover {
    background: black;
  }
`;

The above snippet outputs different CSS in v5 and v6. In v5, there's an implicit & prepended to :hover, so it's applied directly to the element. In v6, it's prepended with & (note the space) to align with the nesting spec for CSS, so the hover state applies to children of the button rather than the button itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went through and added & to the places in Grommet where the & was being implicitly added by styled components v5 so that we will get the same behavior in v5 and v6. (See the changes in StyledCheckBox.js for an example)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not being clear, my concern is moreso in the realm of consumers having this syntax in the .extends properties in their configuration or in styled(SomeGrommetComponent) declarations. Breaking changes that likely won't be documented in Grommet's changelog because they aren't actually changes to Grommet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can add a note to the Grommet release where we add styled components v6 support, so that this doesn't catch anyone by surprise. We have a similar message on the alpha release we did for styled components v6 support: https://github.com/grommet/grommet/releases/tag/v2.35.0-alpha.1.
But ultimately since the breaking change is not caused by Grommet and is a result of the styled-components upgrade then I think the person upgrading would just have to refer to the styled-components upgrade documentation which calls out the breaking changes.
Since we will have support for both v5 and v6 of styled components it is up to the consumer if they want to upgrade to v6 or not.

@@ -522,7 +434,6 @@ exports[`FormField contentProps 1`] = `
<input
autocomplete="off"
class="c5"
value=""
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jcfilben any concerns around this attribute being removed? I'm going to look into it a bit more

Copy link
Collaborator

Choose a reason for hiding this comment

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

I looked a little more, this is a change in the DOM although there's no break to functionality. This is in cases where the input is in a form and the input value is never updating in the DOM since it's managed by the form itself (this is the case regardless of styled-components version) so it moreso seems like it's just cleaning up an empty DOM attribute?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree that it looks like a cleanup. There are other snapshots in this PR that have the same change. It looks like styled components is just stricter and doesn't let an empty value pass into the DOM. I think this snapshot change is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants