-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
placeholder: cleanup placeholder API #102999
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
base: master
Are you sure you want to change the base?
Conversation
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
| }; | ||
|
|
||
| export function ActivityAvatar({className, type, user, size = 38}: Props) { | ||
| export function ActivityAvatar({type, user, size = 38}: Props) { |
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.
There are no more usages of styled activity avatar now
| shape="circle" | ||
| /> | ||
| ); | ||
| return <Placeholder width={`${size}px`} height={`${size}px`} shape="circle" />; |
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 am not a fan of the shape prop. I may just remove it in favor of radius="full" so it follows the Container component convention
| return <Component {...props} chartRef={props.ref} />; | ||
| } | ||
|
|
||
| const ErrorPlaceholder = styled(Placeholder)` |
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.
This is not what we should be using the component for. Given that there were only two instances where this was setup, I've went ahead and made these custom styled. At some point in the future, we will review all usages of styled(CoreComponent), and look at this in more detail, but for now, this is at least not something that we support ootb
| style={{flexGrow: 1, marginBottom: '20px'}} | ||
| /> | ||
| <Container marginBottom="xl"> | ||
| {props => <Placeholder height="20px" width="unset" flexGrow={1} {...props} />} |
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.
Our sizing scale does not support 20px, so this is now 16px.
| children?: React.ReactNode; | ||
| className?: string; | ||
| error?: React.ReactNode; | ||
| height?: string; | ||
| shape?: 'rect' | 'circle'; | ||
| style?: React.CSSProperties; | ||
| testId?: string; | ||
| width?: string; | ||
| } | ||
| shape?: 'circle'; |
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.
Next step is to get it to this
| children?: React.ReactNode; | |
| className?: string; | |
| error?: React.ReactNode; | |
| height?: string; | |
| shape?: 'rect' | 'circle'; | |
| style?: React.CSSProperties; | |
| testId?: string; | |
| width?: string; | |
| } | |
| shape?: 'circle'; | |
| children?: never; |
| background="tertiary" | ||
| width={props.width ?? '100%'} | ||
| height={props.height ?? '60px'} | ||
| radius={shape === 'circle' ? 'full' : (radius ?? 'md')} |
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.
circle is just another way of saying full, and I don't like either of them
| [location.pathname, navigate] | ||
| ); | ||
|
|
||
| const renderEmpty = useCallback((placeholderText = '') => { |
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.
unused
| <SimpleTable.RowCell> | ||
| <div style={{width: '100%'}}> | ||
| <Placeholder height="20px" width="50%" style={{marginBottom: '4px'}} /> | ||
| <ScrapsContainer marginBottom="xs"> |
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.
There is a container component defined in this file, hence the alias
| const LoadingPlaceholder = styled(({className}: PlaceholderProps) => ( | ||
| <Placeholder height="200px" className={className} /> | ||
| ))` | ||
| background-color: ${p => p.theme.surface300}; |
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.
The placeholder tertiary should be fine here
| return ( | ||
| <Container> | ||
| <Placeholder height="100%" error={t('Error loading chart')} /> | ||
| <Container height="100%"> |
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.
Not sure why this container is needed when the Placeholder is a div with 100%, but I've just dropped the styled component here and used the Container from layout
| /> | ||
| ) : ( | ||
| <Placeholder | ||
| shape="rect" |
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.
this is the default
| ) : null} | ||
| </div> | ||
| <Placeholder | ||
| className="Placeholder" |
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.
Unused
|
|
||
| const handleSort = (field: 'name') => { | ||
| const {cursor, navigation, ...queryWithoutPagination} = location.query; | ||
| const {_cursor, _navigation, ...queryWithoutPagination} = location.query; |
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.
Not sure how this got committed, but the linter wasn't happy about unused variables here
Refactor Placeholder to use the new Container API and drop majority of the props. I will followup with removing of the children as well, as this component should not be used as a replacement for empty states.