-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add card mode outlined #2512
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
Merged
Changes from all commits
Commits
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
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,11 @@ | ||
| import React from 'react'; | ||
| import renderer from 'react-test-renderer'; | ||
| import Card from '../../Card/Card'; | ||
|
|
||
| describe('Card', () => { | ||
| it('renders an outlined card', () => { | ||
| const tree = renderer.create(<Card mode="outlined" />).toJSON(); | ||
|
|
||
| expect(tree).toMatchSnapshot(); | ||
| }); | ||
| }); |
33 changes: 33 additions & 0 deletions
33
src/components/__tests__/Card/__snapshots__/Card.test.js.snap
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,33 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Card renders an outlined card 1`] = ` | ||
| <View | ||
| style={ | ||
| Object { | ||
| "backgroundColor": "#ffffff", | ||
| "borderColor": "rgba(0, 0, 0, 0.12)", | ||
| "borderRadius": 4, | ||
| "borderWidth": 1, | ||
| "elevation": 0, | ||
| } | ||
| } | ||
| > | ||
| <View | ||
| accessible={true} | ||
| focusable={false} | ||
| onClick={[Function]} | ||
| onResponderGrant={[Function]} | ||
| onResponderMove={[Function]} | ||
| onResponderRelease={[Function]} | ||
| onResponderTerminate={[Function]} | ||
| onResponderTerminationRequest={[Function]} | ||
| onStartShouldSetResponder={[Function]} | ||
| style={ | ||
| Object { | ||
| "flexGrow": 1, | ||
| "flexShrink": 1, | ||
| } | ||
| } | ||
| /> | ||
| </View> | ||
| `; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the way it's typed currently. The outlined card shouldn't accept elevation prop. Could you try something like that:
I haven't tried that, so it might not work, but I would like to explore this way of handling conditional types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Trancever I tried your approach and it wasn't working at first. So after some time debugging, I found a problem in the HOC
withTheme. I removed it and it worked as follow:Raises error
<Card mode="outlined" elevation={3} />Works
<Card mode="elevated" elevation={3} />After looking up the issue in
withThemeI found a problem in its type declaration here$Withoutit's not working as expected becausePickdoesn't distribute over discriminated union types and you can read more about hereShould we fix the type declaration first?
type $Without<T, K extends keyof any> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should first fix the type of the withTheme HOC. Could you submit a PR? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍 callstack/react-theme-provider#96