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

feat: introduce children function to shorthands #4029

Merged
merged 5 commits into from
Sep 9, 2020

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Aug 11, 2020

This PR adds support for children callback usage in any existing shorthands. This change was originally made for Stardust UI / Fluent UI Northstar (microsoft/fluent-ui-react#1951) which had the more complicated API.

In case of Semantic UI React this will a soft migration to avoid any breaking changes: new API is added and the previous API becomes deprecated. It's expected to remove the old one with functions in V3.

💡 Motivation for changes

#1724 is discussing to add more types for options in Dropdown, the same issue can be met in Menu. In Fluent UI Northstar these issues were solved with kind prop:

<Menu items={[{ kind: 'divider', key: 'divider' }]} />

However, the current implantation with having shorthand as a function blocks it as there is no way to combine { kind: 'smth' } and () => {} 🤔

🔧 Actual changes

The API was introduced and docs were added, now if you would like to customize rendered elements please use children function on any shorthand:

<Button
  content='Like'
  icon={{
    children: (Component, componentProps) => <Component {...componentProps} color='red' />,
    name: 'question',
  }}
/>

To avoid breaking changes in future releases please modify your existing usages:

<Button
  content='Like'
-  icon={(Component, componentProps) => <Component {...componentProps} />}
+  icon={{ children: (Component, componentProps) => <Component {...componentProps} /> }}
/>

The warning was added to inform users about them.


Please share feedback and concerns 👍

@github-actions
Copy link

github-actions bot commented Aug 11, 2020

size-limit report

Path Size
bundle-size/dist/Button.size.js 66.46 KB (+0.11% 🔺)
bundle-size/dist/Icon.size.js 30.65 KB (+0.23% 🔺)
bundle-size/dist/Image.size.js 61.7 KB (+0.12% 🔺)
bundle-size/dist/Modal.size.js 76.72 KB (+0.09% 🔺)
bundle-size/dist/Portal.size.js 47.78 KB (0%)

@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2020

Codecov Report

Merging #4029 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4029   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files         183      183           
  Lines        3280     3280           
=======================================
  Hits         3275     3275           
  Misses          5        5           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d368b9...e1ddd4b. Read the comment docs.

src/generic.d.ts Outdated Show resolved Hide resolved
@layershifter
Copy link
Member Author

Released in semantic-ui-react@1.3.0 🚢

ichim-david added a commit to eea/volto-eea-website-theme that referenced this pull request May 6, 2024
…on usage

- Per the upgrade step we need to have an object with children see
  Semantic-Org/Semantic-UI-React#4029
ichim-david added a commit to eea/volto-eea-website-theme that referenced this pull request May 23, 2024
…k rendering refs #161141 (#238)

* Added back ObjectBrowserWidget.jsx from 17.x.x branch

- before any changes to the anchor adding logic

* style: Automated code fix

* feat(teaser): modified ObjectBrowserWidget and UniversalLink to show links with hashes for manual links

* change(draft-image): to remove image when published date is set to the future

* change(draft-image): show draft image for items with publishing date in the future

- this flips the return value of the previous commit after ticket feedback

* feat(draft-image): added docstrings and unittests for checkIfPublished logic

* fix(performance): Moved language selection logic to LanguageSwitcher.jsx

- This way we don't have to use language selectors in Header.jsx if we are not using this feature which we are not on the EEA website

* perf(header): lazy load LanguageSwitcher

* fix(tests): load the loadable components within Header.test.jsx

* fix(tests): Header.test.jsx after loadable introduction and key missing from TopicsWidget.test.jsx

* fix(tests): several warnings due to bad test configuration

* fix(tests): use render froim testing-library as react-testing-library is depreacated in favor of the previous

* fix(tests): of header giving warning due to Dropdown text with function usage

- Per the upgrade step we need to have an object with children see
  Semantic-Org/Semantic-UI-React#4029

* fix(perf): preload voltoCustom.css in order to avoid layout shift

* Added Image.jsx from Volto 17.x.x before code changes

* style: Automated code fix

* fix(image): block default value selection for Image block size and align option

* change(image): use only mini, preview and large scales for image rendering

- unless the image is full-width from the align section in which case we use the huge scale

* revert lazy loading of voltoCustom.css as it didn't properly parse it as stylesheet

---------

Co-authored-by: eea-jenkins <eea-github@googlegroups.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants