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 🚢

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.

None yet

2 participants