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

✨Overrideable component spike #2410

Merged
merged 10 commits into from
Aug 16, 2022

Conversation

oddvernes
Copy link
Collaborator

resolves #2338 (perhaps)

This solution does seem to work with button, although you need to set as="a" explicitly, as just setting href, which converts it to an a internally, is not picked up by typescript so adding target attribute gets an error in that case.

This pr also fixes a bug i came across where height of button is 36px when as=button, 38px when other things due to different default box-sizing. So i added explicit box-sizing: border-box to force always 36px

@oddvernes
Copy link
Collaborator Author

Tested downstream on a create-react-app with react-router, doing this
<Button as={Link} to="/about">About</Button>
Now works, whereas before you got typescript error, failed to compile

@mimarz
Copy link
Contributor

mimarz commented Aug 12, 2022

Tested downstream on a create-react-app with react-router, doing this <Button as={Link} to="/about">About</Button> Now works, whereas before you got typescript error, failed to compile

Awesome! Did you mean as="a" in this example?

Copy link
Contributor

@mimarz mimarz left a comment

Choose a reason for hiding this comment

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

Wicked! Suggest we add a story and test for testing that the element is casted with some other props specific to the casted element?

Should we still call the casting prop as or something else? The name was primarily used because its what styled-components use 🤔

@oddvernes
Copy link
Collaborator Author

Awesome! Did you mean as="a" in this example?

No, react router has its own Link component with its own attributes like to. It gets transformed into a normal a with href in the html output. But the point is typescript recognizes this and anything else you throw at it now

@mimarz
Copy link
Contributor

mimarz commented Aug 15, 2022

Awesome! Did you mean as="a" in this example?

No, react router has its own Link component with its own attributes like to. It gets transformed into a normal a with href in the html output. But the point is typescript recognizes this and anything else you throw at it now

høh, smart!

@oddvernes oddvernes requested a review from mimarz August 15, 2022 09:44
@oddvernes oddvernes requested a review from mimarz August 16, 2022 07:20
Copy link
Contributor

@mimarz mimarz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@oddvernes oddvernes merged commit 0c31225 into develop Aug 16, 2022
@oddvernes oddvernes deleted the OOVE/2338-overrideable-component-spike branch August 16, 2022 07:40
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this pull request Feb 13, 2024
## [0.5.2](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@0.5.2) (2024-02-13)

### Bug Fixes

* bump @equinor/eds-icons from 0.19.3 to 0.21.0 and @equinor/eds-core-react from 0.33.0 to 0.36.0 in /typescript ([#1892](#1892)) ([c7bd611](c7bd611)), closes [equinor/design-system#2367](equinor/design-system#2367) [equinor/design-system#2431](equinor/design-system#2431) [equinor/design-system#2378](equinor/design-system#2378) [equinor/design-system#2399](equinor/design-system#2399) [equinor/design-system#2410](equinor/design-system#2410) [equinor/design-system#2432](equinor/design-system#2432) [equinor/design-system#2442](equinor/design-system#2442) [equinor/design-system#2420](equinor/design-system#2420) [equinor/design-system#2377](equinor/design-system#2377) [equinor/design-system#2384](equinor/design-system#2384) [equinor/design-system#2405](equinor/design-system#2405) [equinor/design-system#2460](equinor/design-system#2460) [equinor/design-system#2247](equinor/design-system#2247) [equinor/design-system#2436](equinor/design-system#2436) [equinor/design-system#2451](equinor/design-system#2451) [equinor/design-system#2303](equinor/design-system#2303) [equinor/design-system#2327](equinor/design-system#2327) [equinor/design-system#2337](equinor/design-system#2337) [equinor/design-system#2335](equinor/design-system#2335) [equinor/design-system#2313](equinor/design-system#2313) [equinor/design-system#3177](equinor/design-system#3177) [#3239](https://github.com/equinor/webviz-subsurface-components/issues/3239) [#3219](https://github.com/equinor/webviz-subsurface-components/issues/3219) [#3177](https://github.com/equinor/webviz-subsurface-components/issues/3177) [#3137](https://github.com/equinor/webviz-subsurface-components/issues/3137) [#3132](https://github.com/equinor/webviz-subsurface-components/issues/3132) [#3121](https://github.com/equinor/webviz-subsurface-components/issues/3121) [#3020](https://github.com/equinor/webviz-subsurface-components/issues/3020) [#3019](https://github.com/equinor/webviz-subsurface-components/issues/3019)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this pull request Feb 13, 2024
## [1.2.2](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.2.2) (2024-02-13)

### Bug Fixes

* bump @equinor/eds-icons from 0.19.3 to 0.21.0 and @equinor/eds-core-react from 0.33.0 to 0.36.0 in /typescript ([#1892](#1892)) ([c7bd611](c7bd611)), closes [equinor/design-system#2367](equinor/design-system#2367) [equinor/design-system#2431](equinor/design-system#2431) [equinor/design-system#2378](equinor/design-system#2378) [equinor/design-system#2399](equinor/design-system#2399) [equinor/design-system#2410](equinor/design-system#2410) [equinor/design-system#2432](equinor/design-system#2432) [equinor/design-system#2442](equinor/design-system#2442) [equinor/design-system#2420](equinor/design-system#2420) [equinor/design-system#2377](equinor/design-system#2377) [equinor/design-system#2384](equinor/design-system#2384) [equinor/design-system#2405](equinor/design-system#2405) [equinor/design-system#2460](equinor/design-system#2460) [equinor/design-system#2247](equinor/design-system#2247) [equinor/design-system#2436](equinor/design-system#2436) [equinor/design-system#2451](equinor/design-system#2451) [equinor/design-system#2303](equinor/design-system#2303) [equinor/design-system#2327](equinor/design-system#2327) [equinor/design-system#2337](equinor/design-system#2337) [equinor/design-system#2335](equinor/design-system#2335) [equinor/design-system#2313](equinor/design-system#2313) [equinor/design-system#3177](equinor/design-system#3177) [#3239](https://github.com/equinor/webviz-subsurface-components/issues/3239) [#3219](https://github.com/equinor/webviz-subsurface-components/issues/3219) [#3177](https://github.com/equinor/webviz-subsurface-components/issues/3177) [#3137](https://github.com/equinor/webviz-subsurface-components/issues/3137) [#3132](https://github.com/equinor/webviz-subsurface-components/issues/3132) [#3121](https://github.com/equinor/webviz-subsurface-components/issues/3121) [#3020](https://github.com/equinor/webviz-subsurface-components/issues/3020) [#3019](https://github.com/equinor/webviz-subsurface-components/issues/3019)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this pull request Feb 13, 2024
## [0.16.2](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@0.16.2) (2024-02-13)

### Bug Fixes

* bump @equinor/eds-icons from 0.19.3 to 0.21.0 and @equinor/eds-core-react from 0.33.0 to 0.36.0 in /typescript ([#1892](#1892)) ([c7bd611](c7bd611)), closes [equinor/design-system#2367](equinor/design-system#2367) [equinor/design-system#2431](equinor/design-system#2431) [equinor/design-system#2378](equinor/design-system#2378) [equinor/design-system#2399](equinor/design-system#2399) [equinor/design-system#2410](equinor/design-system#2410) [equinor/design-system#2432](equinor/design-system#2432) [equinor/design-system#2442](equinor/design-system#2442) [equinor/design-system#2420](equinor/design-system#2420) [equinor/design-system#2377](equinor/design-system#2377) [equinor/design-system#2384](equinor/design-system#2384) [equinor/design-system#2405](equinor/design-system#2405) [equinor/design-system#2460](equinor/design-system#2460) [equinor/design-system#2247](equinor/design-system#2247) [equinor/design-system#2436](equinor/design-system#2436) [equinor/design-system#2451](equinor/design-system#2451) [equinor/design-system#2303](equinor/design-system#2303) [equinor/design-system#2327](equinor/design-system#2327) [equinor/design-system#2337](equinor/design-system#2337) [equinor/design-system#2335](equinor/design-system#2335) [equinor/design-system#2313](equinor/design-system#2313) [equinor/design-system#3177](equinor/design-system#3177) [#3239](https://github.com/equinor/webviz-subsurface-components/issues/3239) [#3219](https://github.com/equinor/webviz-subsurface-components/issues/3219) [#3177](https://github.com/equinor/webviz-subsurface-components/issues/3177) [#3137](https://github.com/equinor/webviz-subsurface-components/issues/3137) [#3132](https://github.com/equinor/webviz-subsurface-components/issues/3132) [#3121](https://github.com/equinor/webviz-subsurface-components/issues/3121) [#3020](https://github.com/equinor/webviz-subsurface-components/issues/3020) [#3019](https://github.com/equinor/webviz-subsurface-components/issues/3019)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this pull request Feb 13, 2024
## [1.1.2](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.1.2) (2024-02-13)

### Bug Fixes

* bump @equinor/eds-icons from 0.19.3 to 0.21.0 and @equinor/eds-core-react from 0.33.0 to 0.36.0 in /typescript ([#1892](#1892)) ([c7bd611](c7bd611)), closes [equinor/design-system#2367](equinor/design-system#2367) [equinor/design-system#2431](equinor/design-system#2431) [equinor/design-system#2378](equinor/design-system#2378) [equinor/design-system#2399](equinor/design-system#2399) [equinor/design-system#2410](equinor/design-system#2410) [equinor/design-system#2432](equinor/design-system#2432) [equinor/design-system#2442](equinor/design-system#2442) [equinor/design-system#2420](equinor/design-system#2420) [equinor/design-system#2377](equinor/design-system#2377) [equinor/design-system#2384](equinor/design-system#2384) [equinor/design-system#2405](equinor/design-system#2405) [equinor/design-system#2460](equinor/design-system#2460) [equinor/design-system#2247](equinor/design-system#2247) [equinor/design-system#2436](equinor/design-system#2436) [equinor/design-system#2451](equinor/design-system#2451) [equinor/design-system#2303](equinor/design-system#2303) [equinor/design-system#2327](equinor/design-system#2327) [equinor/design-system#2337](equinor/design-system#2337) [equinor/design-system#2335](equinor/design-system#2335) [equinor/design-system#2313](equinor/design-system#2313) [equinor/design-system#3177](equinor/design-system#3177) [#3239](https://github.com/equinor/webviz-subsurface-components/issues/3239) [#3219](https://github.com/equinor/webviz-subsurface-components/issues/3219) [#3177](https://github.com/equinor/webviz-subsurface-components/issues/3177) [#3137](https://github.com/equinor/webviz-subsurface-components/issues/3137) [#3132](https://github.com/equinor/webviz-subsurface-components/issues/3132) [#3121](https://github.com/equinor/webviz-subsurface-components/issues/3121) [#3020](https://github.com/equinor/webviz-subsurface-components/issues/3020) [#3019](https://github.com/equinor/webviz-subsurface-components/issues/3019)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this pull request Feb 13, 2024
## [1.4.2](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.4.2) (2024-02-13)

### Bug Fixes

* bump @equinor/eds-icons from 0.19.3 to 0.21.0 and @equinor/eds-core-react from 0.33.0 to 0.36.0 in /typescript ([#1892](#1892)) ([c7bd611](c7bd611)), closes [equinor/design-system#2367](equinor/design-system#2367) [equinor/design-system#2431](equinor/design-system#2431) [equinor/design-system#2378](equinor/design-system#2378) [equinor/design-system#2399](equinor/design-system#2399) [equinor/design-system#2410](equinor/design-system#2410) [equinor/design-system#2432](equinor/design-system#2432) [equinor/design-system#2442](equinor/design-system#2442) [equinor/design-system#2420](equinor/design-system#2420) [equinor/design-system#2377](equinor/design-system#2377) [equinor/design-system#2384](equinor/design-system#2384) [equinor/design-system#2405](equinor/design-system#2405) [equinor/design-system#2460](equinor/design-system#2460) [equinor/design-system#2247](equinor/design-system#2247) [equinor/design-system#2436](equinor/design-system#2436) [equinor/design-system#2451](equinor/design-system#2451) [equinor/design-system#2303](equinor/design-system#2303) [equinor/design-system#2327](equinor/design-system#2327) [equinor/design-system#2337](equinor/design-system#2337) [equinor/design-system#2335](equinor/design-system#2335) [equinor/design-system#2313](equinor/design-system#2313) [equinor/design-system#3177](equinor/design-system#3177) [#3239](https://github.com/equinor/webviz-subsurface-components/issues/3239) [#3219](https://github.com/equinor/webviz-subsurface-components/issues/3219) [#3177](https://github.com/equinor/webviz-subsurface-components/issues/3177) [#3137](https://github.com/equinor/webviz-subsurface-components/issues/3137) [#3132](https://github.com/equinor/webviz-subsurface-components/issues/3132) [#3121](https://github.com/equinor/webviz-subsurface-components/issues/3121) [#3020](https://github.com/equinor/webviz-subsurface-components/issues/3020) [#3019](https://github.com/equinor/webviz-subsurface-components/issues/3019)
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.

Polymorphic types for our "casted" components
2 participants