Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3150 from bbc/update-story-promo
Browse files Browse the repository at this point in the history
Story Promo - Fallback spacing for Leading promo
  • Loading branch information
PriyaKR authored Feb 20, 2020
2 parents 3e7ae91 + c72fab9 commit 22835c8
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/components/psammead-story-promo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
| ------- | ----------- |
| 4.0.0-alpha.13 | [PR#3150](https://github.com/bbc/psammead/pull/3150) Fix fallback width for Leading promo |
| 4.0.0-alpha.12 | [PR#3135](https://github.com/bbc/psammead/pull/3135) Talos - Bump Dependencies - @bbc/gel-foundations |
| 4.0.0-alpha.11 | [PR#3136](https://github.com/bbc/psammead/pull/3136) Fix visually hidden text so it isn't split across multiple strings. |
| 4.0.0-alpha.10 | [PR#3129](https://github.com/bbc/psammead/pull/3129) Talos - Bump Dependencies - @bbc/gel-foundations |
Expand Down
1 change: 1 addition & 0 deletions packages/components/psammead-story-promo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The `StoryPromo` component is designed to be used on 'index' pages, which are pa
| image | node | no | Null | `<img>` |
| info | node | yes | N/A | `<h2>Title</h2>` |
| mediaIndicator | node | no | null | `<MediaIndicator duration="2:15" datetime="PT2M15S" offscreenText="Video 2 minutes 15 seconds" />` |
| dir | string | no | `ltr` | `rtl` |
| displayImage | boolean | no | true | false |
| promoType | string | no | `regular` | `top` |

Expand Down
2 changes: 1 addition & 1 deletion packages/components/psammead-story-promo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/psammead-story-promo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-story-promo",
"version": "4.0.0-alpha.12",
"version": "4.0.0-alpha.13",
"main": "dist/index.js",
"module": "esm/index.js",
"sideEffects": false,
Expand Down
4 changes: 4 additions & 0 deletions packages/components/psammead-story-promo/src/ImageStyles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ImageGridColumns = css`
`;

const ImageGridColumnsLeadingStory = css`
padding: 0;
grid-template-columns: repeat(6, 1fr);
grid-column-end: span 6;
Expand Down Expand Up @@ -72,10 +73,13 @@ const ImageGridFallback = css`
}
`;

const paddingDir = ({ dir }) => `padding-${dir === 'rtl' ? 'right' : 'left'}`;

const ImageGridFallbackLeadingStory = css`
width: ${fullWidthColumnsMaxScaleable};
@media (min-width: ${GEL_GROUP_3_SCREEN_WIDTH_MIN}) {
${paddingDir}: ${GEL_SPACING};
width: ${halfWidthColumnsMaxScaleable};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/components/psammead-story-promo/src/TextStyles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const fullWidthColumnsMaxScaleable = `100%`;

const halfWidthColumnsMaxScaleable = `50%`;

const paddingDir = ({ dir }) => `padding-${dir === 'rtl' ? 'left' : 'right'}`;

const TextGridColumnsTopStory = css`
grid-column: 1 / span 6;
Expand All @@ -42,6 +44,7 @@ ${({ displayImage }) => !displayImage && `grid-column: 1 / span 6;`}
`;

const TextGridColumnsLeadingStory = css`
padding: 0;
width: 100%;
grid-template-columns: repeat(6, 1fr);
grid-column-end: span 6;
Expand Down Expand Up @@ -90,6 +93,7 @@ const TextGridFallback = css`
const TextGridFallBackLeadingStory = css`
width: ${fullWidthColumnsMaxScaleable};
@media (min-width: ${GEL_GROUP_3_SCREEN_WIDTH_MIN}) {
${paddingDir}: ${GEL_SPACING};
width: ${halfWidthColumnsMaxScaleable};
}
@media (min-width: ${GEL_GROUP_4_SCREEN_WIDTH_MIN}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ exports[`StoryPromo - Leading Story should render correctly 1`] = `
@media (min-width:37.5rem) {
.c5 {
padding-left: 0.5rem;
width: 50%;
}
}
Expand All @@ -88,13 +89,15 @@ exports[`StoryPromo - Leading Story should render correctly 1`] = `
@supports (grid-template-columns:fit-content(200px)) {
.c5 {
width: initial;
padding: 0;
grid-template-columns: repeat(6,1fr);
grid-column-end: span 6;
}
}
@media (min-width:37.5rem) {
.c1 {
padding-right: 0.5rem;
width: 50%;
}
}
Expand All @@ -110,6 +113,7 @@ exports[`StoryPromo - Leading Story should render correctly 1`] = `
display: block;
width: initial;
padding: initial;
padding: 0;
width: 100%;
grid-template-columns: repeat(6,1fr);
grid-column-end: span 6;
Expand Down Expand Up @@ -177,6 +181,7 @@ exports[`StoryPromo - Leading Story should render correctly 1`] = `
>
<div
class="c1"
dir="ltr"
>
<h3
class="c2"
Expand All @@ -199,6 +204,7 @@ exports[`StoryPromo - Leading Story should render correctly 1`] = `
</div>
<div
class="c5"
dir="ltr"
>
<div
class="c6"
Expand Down Expand Up @@ -347,6 +353,7 @@ exports[`StoryPromo - Leading Story should render with Media Indicator correctly
@media (min-width:37.5rem) {
.c5 {
padding-left: 0.5rem;
width: 50%;
}
}
Expand All @@ -360,13 +367,15 @@ exports[`StoryPromo - Leading Story should render with Media Indicator correctly
@supports (grid-template-columns:fit-content(200px)) {
.c5 {
width: initial;
padding: 0;
grid-template-columns: repeat(6,1fr);
grid-column-end: span 6;
}
}
@media (min-width:37.5rem) {
.c1 {
padding-right: 0.5rem;
width: 50%;
}
}
Expand All @@ -382,6 +391,7 @@ exports[`StoryPromo - Leading Story should render with Media Indicator correctly
display: block;
width: initial;
padding: initial;
padding: 0;
width: 100%;
grid-template-columns: repeat(6,1fr);
grid-column-end: span 6;
Expand Down Expand Up @@ -449,6 +459,7 @@ exports[`StoryPromo - Leading Story should render with Media Indicator correctly
>
<div
class="c1"
dir="ltr"
>
<h3
class="c2"
Expand All @@ -471,6 +482,7 @@ exports[`StoryPromo - Leading Story should render with Media Indicator correctly
</div>
<div
class="c5"
dir="ltr"
>
<div
class="c6"
Expand Down Expand Up @@ -678,6 +690,7 @@ exports[`StoryPromo - Top Story should render correctly 1`] = `
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand All @@ -690,6 +703,7 @@ exports[`StoryPromo - Top Story should render correctly 1`] = `
</div>
<div
class="c3"
dir="ltr"
>
<h3
class="c4"
Expand Down Expand Up @@ -936,6 +950,7 @@ exports[`StoryPromo - Top Story should render with Media Indicator correctly 1`]
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand Down Expand Up @@ -979,6 +994,7 @@ exports[`StoryPromo - Top Story should render with Media Indicator correctly 1`]
</div>
<div
class="c8"
dir="ltr"
>
<h3
class="c9"
Expand Down Expand Up @@ -1286,6 +1302,7 @@ exports[`StoryPromo - Top Story should render with multiple Index Alsos correctl
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand All @@ -1298,6 +1315,7 @@ exports[`StoryPromo - Top Story should render with multiple Index Alsos correctl
</div>
<div
class="c3"
dir="ltr"
>
<h3
class="c4"
Expand Down Expand Up @@ -1676,6 +1694,7 @@ exports[`StoryPromo - Top Story should render with one Index Also correctly 1`]
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand All @@ -1688,6 +1707,7 @@ exports[`StoryPromo - Top Story should render with one Index Also correctly 1`]
</div>
<div
class="c3"
dir="ltr"
>
<h3
class="c4"
Expand Down Expand Up @@ -1954,6 +1974,7 @@ exports[`StoryPromo should render Live promo correctly 1`] = `
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand All @@ -1966,6 +1987,7 @@ exports[`StoryPromo should render Live promo correctly 1`] = `
</div>
<div
class="c3"
dir="ltr"
>
<h3
class="c4"
Expand Down Expand Up @@ -2193,6 +2215,7 @@ exports[`StoryPromo should render a RTL Live promo correctly 1`] = `
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand All @@ -2205,6 +2228,7 @@ exports[`StoryPromo should render a RTL Live promo correctly 1`] = `
</div>
<div
class="c3"
dir="ltr"
>
<h3
class="c4"
Expand Down Expand Up @@ -2411,6 +2435,7 @@ exports[`StoryPromo should render correctly 1`] = `
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand All @@ -2423,6 +2448,7 @@ exports[`StoryPromo should render correctly 1`] = `
</div>
<div
class="c3"
dir="ltr"
>
<h3
class="c4"
Expand Down Expand Up @@ -2681,6 +2707,7 @@ exports[`StoryPromo with Media Indicator should render a RTL promo with media in
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand Down Expand Up @@ -2724,6 +2751,7 @@ exports[`StoryPromo with Media Indicator should render a RTL promo with media in
</div>
<div
class="c8"
dir="ltr"
>
<h3
class="c9"
Expand Down Expand Up @@ -2982,6 +3010,7 @@ exports[`StoryPromo with Media Indicator should render correctly 1`] = `
>
<div
class="c1"
dir="ltr"
>
<div
class="c2"
Expand Down Expand Up @@ -3025,6 +3054,7 @@ exports[`StoryPromo with Media Indicator should render correctly 1`] = `
</div>
<div
class="c8"
dir="ltr"
>
<h3
class="c9"
Expand Down
9 changes: 6 additions & 3 deletions packages/components/psammead-story-promo/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const wrapperStyles = {
};

const StoryPromoWrapper = styled.div`
position: relative;
position: relative; /* This is needed to contain the faux-block-link to the Story Promo */
@supports (${grid}) {
display: grid;
grid-template-columns: repeat(6, 1fr);
Expand Down Expand Up @@ -250,13 +250,14 @@ const StoryPromo = ({
image,
info,
promoType,
dir,
displayImage,
mediaIndicator,
mediaIndicatorIsInline,
...props
}) => {
const renderImage = displayImage && (
<ImageGridItem promoType={promoType}>
<ImageGridItem dir={dir} promoType={promoType}>
<ImageContentsWrapper>
{image}
{mediaIndicator && (
Expand All @@ -272,7 +273,7 @@ const StoryPromo = ({
);

const renderText = (
<TextGridItem promoType={promoType} displayImage={displayImage}>
<TextGridItem promoType={promoType} dir={dir} displayImage={displayImage}>
{!displayImage && mediaIndicator}
{info}
</TextGridItem>
Expand All @@ -296,6 +297,7 @@ const StoryPromo = ({
};

StoryPromo.propTypes = {
dir: oneOf(['ltr', 'rtl']),
image: node.isRequired,
info: node.isRequired,
promoType: PROMO_TYPES,
Expand All @@ -305,6 +307,7 @@ StoryPromo.propTypes = {
};

StoryPromo.defaultProps = {
dir: 'ltr',
promoType: 'regular',
displayImage: true,
mediaIndicator: null,
Expand Down
Loading

0 comments on commit 22835c8

Please sign in to comment.