Skip to content

Commit

Permalink
feat: replat 6101 edition slices keylines (newsuk#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
parkjh committed May 1, 2019
1 parent 6f5ed93 commit 4919482
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"prefmt": "prettier --write '**/*.{js,json}'",
"fmt": "lerna run fmt",
"cinstall": "./lib/custom_install.sh",
"clean": "rm -rf ./**/node_modules/",
"clean": "git clean -xdf",
"bundle": "lerna run bundle",
"build:local": "yarn install && yarn bundle && yarn prepublishOnly",
"postinstall": "yarn run fetch-fonts && lerna run postinstall && lerna run transpile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ exports[`2. leaders 2`] = `
exports[`3. lead one and one 1`] = `
<View>
<TileA />
<View
style={
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
}
}
/>
<TileB />
</View>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ exports[`3. lead one and one 1`] = `
<TileA
tileName="lead"
/>
<View />
<TileB
tileName="support"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ exports[`2. leaders 2`] = `
exports[`3. lead one and one 1`] = `
<View>
<TileA />
<View
style={
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
}
}
/>
<TileB />
</View>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ exports[`3. lead one and one 1`] = `
<TileA
tileName="lead"
/>
<View />
<TileB
tileName="support"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Sunday Times magazine section 1`] = `
<RCTScrollView
style={
Object {
"paddingTop": 20,
"paddingTop": 10,
}
}
>
Expand Down Expand Up @@ -87,7 +87,7 @@ exports[`Times magazine section 1`] = `
<RCTScrollView
style={
Object {
"paddingTop": 20,
"paddingTop": 10,
}
}
>
Expand Down Expand Up @@ -247,7 +247,7 @@ exports[`section page 1`] = `
<RCTScrollView
style={
Object {
"paddingTop": 20,
"paddingTop": 10,
}
}
>
Expand All @@ -260,6 +260,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -273,6 +274,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -286,6 +288,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -299,6 +302,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -312,6 +316,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Sunday Times magazine section 1`] = `
<RCTScrollView
style={
Object {
"paddingTop": 20,
"paddingTop": 10,
}
}
>
Expand Down Expand Up @@ -87,7 +87,7 @@ exports[`Times magazine section 1`] = `
<RCTScrollView
style={
Object {
"paddingTop": 20,
"paddingTop": 10,
}
}
>
Expand Down Expand Up @@ -247,7 +247,7 @@ exports[`section page 1`] = `
<RCTScrollView
style={
Object {
"paddingTop": 20,
"paddingTop": 10,
}
}
>
Expand All @@ -260,6 +260,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -273,6 +274,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -286,6 +288,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -299,6 +302,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand All @@ -312,6 +316,7 @@ exports[`section page 1`] = `
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
"marginHorizontal": 20,
}
}
/>
Expand Down
43 changes: 35 additions & 8 deletions packages/section/src/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Section extends Component {
constructor(props) {
super(props);
this.renderItem = this.renderItem.bind(this);
this.renderItemSeperator = this.renderItemSeperator.bind(this);
this.onViewableItemsChanged = this.onViewableItemsChanged.bind(this);
}

Expand Down Expand Up @@ -43,6 +44,7 @@ class Section extends Component {

return <MagazineCover cover={cover} />;
}

return null;
}

Expand All @@ -64,6 +66,24 @@ class Section extends Component {
);
}

renderItemSeperator({ leadingItem }) {
const {
section: { name }
} = this.props;
const isPuzzle = name === "PuzzleSection";
const isIgnored = leadingItem.ignoreSeparator;

if (isPuzzle || isIgnored) {
return null;
}

return (
<View style={styles.listItemSeparatorContainer}>
<SectionItemSeparator />
</View>
);
}

render() {
const {
section: { name, slices },
Expand All @@ -79,21 +99,28 @@ class Section extends Component {

if (slices) receiveChildList(data);

const excludeSliceNames = ["LeadersSlice", "DailyUniversalRegister"];
const sliceNames = data.map(slice => slice.name);
const sliceIndices = excludeSliceNames.reduce((acc, sliceName) => {
const index = sliceNames.indexOf(sliceName);
if (index > 0) {
return [...acc, index - 1, index];
}

return acc;
}, []);
sliceIndices.forEach(index => {
data[index].ignoreSeparator = true;
});

return (
<Responsive>
<ResponsiveContext.Consumer>
{({ isTablet }) => (
<FlatList
data={data}
initialNumToRender={5}
ItemSeparatorComponent={
!isPuzzle &&
(() => (
<View style={styles.listItemSeparatorContainer}>
<SectionItemSeparator />
</View>
))
}
ItemSeparatorComponent={this.renderItemSeperator}
keyExtractor={item => item.elementId}
ListHeaderComponent={this.getHeaderComponent(
isPuzzle,
Expand Down
5 changes: 3 additions & 2 deletions packages/section/src/styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const styles = StyleSheet.create({
},
listItemSeparator: {
backgroundColor: colours.functional.keyline,
height: 1
height: 1,
marginHorizontal: spacing(4)
},
puzzleBarArrow: {
paddingLeft: spacing(2),
Expand All @@ -27,7 +28,7 @@ const styles = StyleSheet.create({
fontSize: 20
},
tabletSpacing: {
paddingTop: spacing(4)
paddingTop: spacing(2)
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ exports[`1. lead one and one - small 1`] = `
<Text>
lead
</Text>
<View
style={
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
}
}
/>
<Text>
support
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`1. lead one and one - small 1`] = `
<Text>
lead
</Text>
<View />
<Text>
support
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ exports[`1. lead one and one - small 1`] = `
<Text>
lead
</Text>
<View
style={
Object {
"backgroundColor": "#DBDBDB",
"height": 1,
}
}
/>
<Text>
support
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`1. lead one and one - small 1`] = `
<Text>
lead
</Text>
<View />
<Text>
support
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ exports[`1. lead one and one - small 1`] = `
>
lead
</div>
<div
className="S1"
style={
Object {
"backgroundColor": "rgba(219,219,219,1.00)",
"height": "1px",
}
}
/>
<div
className="S1"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`1. lead one and one - small 1`] = `
<div>
lead
</div>
<div />
<div>
support
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/slice-layout/src/templates/leadoneandone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const leadOneAndOneSlice = ({ breakpoint, lead, support }) => {
return (
<View>
{lead}
<View style={styles.keyline} />
{support}
</View>
);
Expand Down
6 changes: 5 additions & 1 deletion packages/slice-layout/src/templates/leadoneandone/styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spacing } from "@times-components/styleguide";
import { spacing, colours } from "@times-components/styleguide";

const styles = {
container: {
Expand All @@ -9,6 +9,10 @@ const styles = {
leadItem: {
width: "83.33%"
},
keyline: {
backgroundColor: colours.functional.keyline,
height: 1
},
supportItem: {
width: "16.67%"
}
Expand Down

0 comments on commit 4919482

Please sign in to comment.