-
Notifications
You must be signed in to change notification settings - Fork 30
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(PreviewTip): add preview tip #2923
Merged
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
1647c73
feat(PreviewTip): add preview tip
dreamwasp 35af5f6
start on visuals
dreamwasp 1392114
Merge branch 'main' into cass-gm-645
dreamwasp eb86a45
start breaking things into elements + type work
dreamwasp f5b6605
start working on pattern stuff
dreamwasp 11d859d
Merge branch 'main' into cass-gm-645
dreamwasp c80f844
sort content props + shadow offset
dreamwasp aa1d538
Merge branch 'main' into cass-gm-645
dreamwasp 9f14afa
wip
dreamwasp 2db226a
Merge branch 'cass-gm-645' of ssh://github.com/Codecademy/gamut into …
dreamwasp 2c61386
Merge branch 'main' into cass-gm-645
dreamwasp 57d643a
more work on overline + avatar prop
dreamwasp f1cfb8f
shadow working and avatar props cleaned up
dreamwasp 7a25246
need to adjust shadow width, but mostly good
dreamwasp 9648591
temp width change
dreamwasp a8f1f09
start flexi
dreamwasp cabd249
start working on inline descriptions
dreamwasp 29bb468
more storybook fixes + avatar sizing gucci :sparkles:
dreamwasp 89228a5
Merge branch 'main' into cass-gm-645
dreamwasp 99f64b7
fix tooltip alignment
dreamwasp 2b0cb28
Merge branch 'cass-gm-645' of ssh://github.com/Codecademy/gamut into …
dreamwasp 26ac884
more progress on PreviewTip, need to fix infotip floating sizing
dreamwasp 8865e51
floating widths sorted
dreamwasp 31febbc
spacing stuff fixed, start loading work
dreamwasp c955d3b
test loading prop
dreamwasp ee7892e
dine with loading state
dreamwasp d3098e7
fix this test, figure out other things tomorrow
dreamwasp 254b5f5
Merge branch 'main' into cass-gm-645
dreamwasp 144a815
Merge branch 'main' into cass-gm-645
dreamwasp 62611a6
dedupe patterns
dreamwasp cf0969a
Merge branch 'main' into cass-gm-645
dreamwasp 3d54f01
fix more :)
dreamwasp db53846
Merge branch 'cass-gm-645' of ssh://github.com/Codecademy/gamut into …
dreamwasp d3847e5
format fix
dreamwasp f8e97d3
fix circular deps
dreamwasp e5c25fc
shadow fixed, may need de-duping
dreamwasp 86e380c
fix shadows
dreamwasp f6dd55f
add delay to inline styles
dreamwasp 5836f43
add transition delays
dreamwasp 0825fc7
start styling
dreamwasp 9e0378d
real pkg
dreamwasp 2ebc53f
real pkg
dreamwasp 09ca971
Merge branch 'main' into cass-gm-645
dreamwasp d499e75
start working on better docs
dreamwasp 5368676
Merge branch 'cass-gm-645' of ssh://github.com/Codecademy/gamut into …
dreamwasp 2bd89b5
avatar hover styles
dreamwasp 0bccc14
more docs + fix truncation
dreamwasp 0821d35
floating widths sorted + responsive grid row gaps
dreamwasp eb6abfa
busy status for loading text
dreamwasp adb00a6
tests
dreamwasp 0af64e1
more work on tests
dreamwasp 6c4bc86
more work on tests
dreamwasp 213a67c
format + change popover defaults back
dreamwasp d6ad23c
fix tests
dreamwasp 6f5a7c5
lint + fix loading
dreamwasp e45d692
Merge branch 'main' into cass-gm-645
dreamwasp 47bbb75
Merge branch 'main' into cass-gm-645
dreamwasp 914286b
amy edit pt1
dreamwasp 28fb8b2
fix other stuff
dreamwasp 0685764
Merge branch 'main' into cass-gm-645
dreamwasp d8810dd
format stuff
dreamwasp af046b9
Merge branch 'cass-gm-645' of ssh://github.com/Codecademy/gamut into …
dreamwasp e9aa6fe
awkward overline text;
dreamwasp adaf964
fix exmaple
dreamwasp bb6348e
try on pr env
dreamwasp c130411
rm unused import
dreamwasp 4e6dd73
fix aria-live region
dreamwasp 30b741a
fix tests + spacing
dreamwasp 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 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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
export const timingValues = { | ||
fast: 150, | ||
medium: 200, | ||
base: 300, | ||
slow: 350, | ||
}; | ||
|
||
export const timing = { | ||
fast: `${timingValues.fast}ms`, | ||
medium: `${timingValues.medium}ms`, | ||
base: `${timingValues.base}ms`, | ||
slow: `${timingValues.slow}ms`, | ||
}; |
This file contains 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 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 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 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 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 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 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 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 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 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 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,156 @@ | ||
import { CheckerDense } from '@codecademy/gamut-patterns'; | ||
import { css, variant } from '@codecademy/gamut-styles'; | ||
import styled from '@emotion/styled'; | ||
import { useMemo } from 'react'; | ||
|
||
import { Anchor } from '../../Anchor'; | ||
import { Box, FlexBox, GridBox } from '../../Box'; | ||
import { ButtonSelectors } from '../../ButtonBase/ButtonBase'; | ||
import { Shimmer } from '../../Loading/Shimmer'; | ||
import { patternContainerBaseStyles } from '../../Popover/styles'; | ||
import { Text } from '../../Typography'; | ||
import { PreviewTipContent, TipPlacementComponentProps } from '../shared/types'; | ||
import { | ||
avatarColumnTemplate, | ||
avatarGridTemplate, | ||
defaultGridTemplate, | ||
getShadowAlignment, | ||
} from './styles'; | ||
|
||
export const PreviewTipAnchor = styled(Anchor)( | ||
variant({ | ||
defaultVariant: 'anchor', | ||
prop: 'tipType', | ||
variants: { | ||
anchor: { | ||
textDecorationStyle: 'dotted', | ||
[ButtonSelectors.HOVER]: { | ||
textDecoration: 'underline', | ||
textDecorationStyle: 'solid', | ||
}, | ||
}, | ||
avatar: { | ||
borderRadius: 'sm', | ||
[ButtonSelectors.HOVER]: { | ||
bg: 'background-hover', | ||
}, | ||
}, | ||
}, | ||
}) | ||
); | ||
|
||
const PreviewTipBodyShimmer = ({ | ||
avatar, | ||
truncateLines = 4, | ||
}: Pick<PreviewTipContent, 'avatar' | 'truncateLines'>) => { | ||
const lineHeight = 24; | ||
const height = avatar ? lineHeight : (truncateLines as number) * lineHeight; | ||
const width = avatar ? '5.5rem' : '100%'; | ||
return ( | ||
<> | ||
<Shimmer height={lineHeight} width="4.5rem" /> | ||
<Shimmer height={height} width={width} /> | ||
</> | ||
); | ||
}; | ||
|
||
type PreviewTipContentsProps = Pick<TipPlacementComponentProps, 'info'> & | ||
PreviewTipContent; | ||
|
||
export const PreviewTipContents: React.FC<PreviewTipContentsProps> = ({ | ||
avatar, | ||
loading, | ||
info, | ||
overline, | ||
truncateLines = 4, | ||
username, | ||
}) => { | ||
const gridTemplateAreas = useMemo(() => { | ||
if (!avatar) return defaultGridTemplate; | ||
|
||
let avatarGridTemplateString = ''; | ||
|
||
[info, overline, username].forEach((el) => { | ||
if (el) | ||
avatarGridTemplateString = avatarGridTemplateString.concat( | ||
`\n`, | ||
avatarGridTemplate | ||
); | ||
}); | ||
|
||
return avatarGridTemplateString; | ||
}, [avatar, info, overline, username]); | ||
|
||
const contents = useMemo(() => { | ||
return loading ? ( | ||
<PreviewTipBodyShimmer avatar={avatar} truncateLines={truncateLines} /> | ||
) : ( | ||
<> | ||
{overline && ( | ||
<Text textColor="text-secondary" fontFamily="accent" fontSize={14}> | ||
{overline} | ||
</Text> | ||
)} | ||
{username && ( | ||
<Text fontWeight="bold" fontSize={16}> | ||
{username} | ||
</Text> | ||
)} | ||
<Text | ||
as="p" | ||
fontSize={16} | ||
truncate="ellipsis" | ||
truncateLines={truncateLines ?? 4} | ||
> | ||
{info} | ||
</Text> | ||
</> | ||
); | ||
}, [loading, avatar, info, overline, truncateLines, username]); | ||
|
||
return ( | ||
<GridBox | ||
gridTemplateAreas={gridTemplateAreas} | ||
gridTemplateColumns={avatar ? avatarColumnTemplate : '1fr'} | ||
rowGap={4} | ||
> | ||
{avatar && ( | ||
<FlexBox center aria-hidden gridArea="avatar" pr={12}> | ||
<Box height={40} width={40}> | ||
{avatar} | ||
</Box> | ||
</FlexBox> | ||
)} | ||
{contents} | ||
</GridBox> | ||
); | ||
}; | ||
|
||
type PreviewTipShadowProps = Pick< | ||
TipPlacementComponentProps, | ||
'alignment' | 'zIndex' | ||
>; | ||
|
||
export const PreviewTipPattern = styled(Box)( | ||
css({ | ||
height: 'calc(100% - 12px)', | ||
...patternContainerBaseStyles, | ||
}) | ||
); | ||
|
||
export const PreviewTipShadow: React.FC<PreviewTipShadowProps> = ({ | ||
alignment, | ||
zIndex, | ||
}) => { | ||
const shadowAlignment = getShadowAlignment(alignment); | ||
|
||
return ( | ||
<PreviewTipPattern | ||
aria-hidden | ||
zIndex={zIndex ? zIndex - 2 : -1} | ||
{...shadowAlignment} | ||
> | ||
<CheckerDense /> | ||
</PreviewTipPattern> | ||
); | ||
}; |
Oops, something went wrong.
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.
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.
should the
1fr
here be usingdefaultGridTemplate
?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.
good call, thank you!