-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework trail text visibility logic & show on all breakpoints in flexi…
…ble/general (#12584) * rework trail text visibility logic * reorder trail text logic to ensure it shows on splash for all breakpoints
- Loading branch information
Showing
5 changed files
with
93 additions
and
126 deletions.
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
71 changes: 71 additions & 0 deletions
71
dotcom-rendering/src/components/Card/components/TrailText.tsx
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,71 @@ | ||
import { css } from '@emotion/react'; | ||
import { | ||
from, | ||
space, | ||
textSans14, | ||
textSans17, | ||
} from '@guardian/source/foundations'; | ||
import { Hide } from '@guardian/source/react-components'; | ||
import { palette } from '../../../palette'; | ||
|
||
export type TrailTextSize = 'regular' | 'large'; | ||
|
||
type Props = { | ||
trailText: string; | ||
trailTextSize?: TrailTextSize; | ||
/** Optionally overrides the trail text colour */ | ||
trailTextColour?: string; | ||
/** Controls visibility of trail text on various breakpoints */ | ||
hideUntil?: 'tablet' | 'desktop'; | ||
/** Adds padding to the top of the trail text */ | ||
padTop: boolean; | ||
}; | ||
|
||
const trailTextStyles = css` | ||
display: flex; | ||
flex-direction: column; | ||
padding-bottom: ${space[2]}px; | ||
`; | ||
|
||
const topPadding = css` | ||
padding-top: ${space[2]}px; | ||
`; | ||
|
||
const fontStyles = (trailTextSize: TrailTextSize) => css` | ||
${textSans14} | ||
${from.desktop} { | ||
${trailTextSize === 'large' && textSans17} | ||
} | ||
strong { | ||
font-weight: bold; | ||
} | ||
`; | ||
|
||
export const TrailText = ({ | ||
trailText: text, | ||
trailTextSize = 'regular', | ||
trailTextColour = palette('--card-trail-text'), | ||
hideUntil, | ||
padTop, | ||
}: Props) => { | ||
const trailText = ( | ||
<div | ||
css={[ | ||
trailTextStyles, | ||
css` | ||
color: ${trailTextColour}; | ||
`, | ||
fontStyles(trailTextSize), | ||
padTop && topPadding, | ||
]} | ||
dangerouslySetInnerHTML={{ | ||
__html: text, | ||
}} | ||
/> | ||
); | ||
return hideUntil ? ( | ||
<Hide until={hideUntil}>{trailText}</Hide> | ||
) : ( | ||
<>{trailText}</> | ||
); | ||
}; |
106 changes: 0 additions & 106 deletions
106
dotcom-rendering/src/components/Card/components/TrailTextWrapper.tsx
This file was deleted.
Oops, something went wrong.
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