Improve layout of screenshots and videos

Summary: The previous table was ugly, and weirdly interactive. This diff changes it to a static layout

Reviewed By: priteshrnandgaonkar

Differential Revision: D18744712

fbshipit-source-id: 9060da07eae836a94ce6d8bb2ebb8a6a54470daa
This commit is contained in:
Michel Weststrate
2019-11-29 06:20:29 -08:00
committed by Facebook Github Bot
parent 92bbccb6e0
commit 2bd87a8100
3 changed files with 49 additions and 8 deletions

View File

@@ -0,0 +1,35 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React from 'react';
import Bordered from './Bordered';
import {colors} from './colors';
/**
* Displays all children in a bordered, zebra styled vertical layout
*/
const AlternatingRows: React.FC<{children: React.ReactNode[]}> = ({
children,
}) => (
<Bordered style={{flexDirection: 'column'}}>
{children.map((child, idx) => (
<div
key={idx}
style={{
padding: 8,
background: idx % 2 === 0 ? colors.light02 : colors.white,
}}>
{child}
</div>
))}
</Bordered>
);
export default AlternatingRows;

View File

@@ -16,10 +16,12 @@ import FlexRow from './FlexRow';
* It takes two children, 'left' and 'right'. One is assumed to have a fixed (or minimum) size, * It takes two children, 'left' and 'right'. One is assumed to have a fixed (or minimum) size,
* and the other will grow automatically * and the other will grow automatically
*/ */
const HBoxContainer = styled(FlexRow)({ const HBoxContainer = styled(FlexRow)(
shrink: 0, ({verticalAlign}: {verticalAlign: string}) => ({
alignItems: 'center', shrink: 0,
}); alignItems: verticalAlign,
}),
);
HBoxContainer.displayName = 'HBoxContainer'; HBoxContainer.displayName = 'HBoxContainer';
@@ -27,7 +29,8 @@ const HBox: React.FC<{
children: [] | [React.ReactNode] | [React.ReactNode, React.ReactNode]; children: [] | [React.ReactNode] | [React.ReactNode, React.ReactNode];
grow?: 'left' | 'right' | 'auto'; grow?: 'left' | 'right' | 'auto';
childWidth?: number; childWidth?: number;
}> = ({children, grow, childWidth}) => { verticalAlign?: 'center' | 'top';
}> = ({children, grow, childWidth, verticalAlign}) => {
if (children.length > 2) { if (children.length > 2) {
throw new Error('HBox expects at most 2 children'); throw new Error('HBox expects at most 2 children');
} }
@@ -45,25 +48,26 @@ const HBox: React.FC<{
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
} as const; } as const;
const vAlign = verticalAlign === 'top' ? 'normal' : 'center';
switch (grow) { switch (grow) {
case 'right': case 'right':
return ( return (
<HBoxContainer> <HBoxContainer verticalAlign={vAlign}>
<div style={{...fixedStyle, marginRight: 8}}>{left}</div> <div style={{...fixedStyle, marginRight: 8}}>{left}</div>
<div style={growStyle}>{right}</div> <div style={growStyle}>{right}</div>
</HBoxContainer> </HBoxContainer>
); );
case 'left': case 'left':
return ( return (
<HBoxContainer> <HBoxContainer verticalAlign={vAlign}>
<div style={growStyle}>{left}</div> <div style={growStyle}>{left}</div>
<div style={{...fixedStyle, marginLeft: 8}}>{right}</div> <div style={{...fixedStyle, marginLeft: 8}}>{right}</div>
</HBoxContainer> </HBoxContainer>
); );
default: default:
return ( return (
<HBoxContainer> <HBoxContainer verticalAlign={vAlign}>
<div style={growStyle}>{left}</div> <div style={growStyle}>{left}</div>
<div style={{...growStyle, marginLeft: 8}}>{right}</div> <div style={{...growStyle, marginLeft: 8}}>{right}</div>
</HBoxContainer> </HBoxContainer>
@@ -73,6 +77,7 @@ const HBox: React.FC<{
HBox.defaultProps = { HBox.defaultProps = {
grow: 'right', grow: 'right',
childWidth: 0, childWidth: 0,
verticalAlign: 'center',
}; };
HBox.displayName = 'HBox'; HBox.displayName = 'HBox';

View File

@@ -169,3 +169,4 @@ export {default as RoundedSection} from './components/RoundedSection';
export {default as CenteredView} from './components/CenteredView'; export {default as CenteredView} from './components/CenteredView';
export {default as Info} from './components/Info'; export {default as Info} from './components/Info';
export {default as Bordered} from './components/Bordered'; export {default as Bordered} from './components/Bordered';
export {default as AlternatingRows} from './components/AlternatingRows';