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:
committed by
Facebook Github Bot
parent
92bbccb6e0
commit
2bd87a8100
35
src/ui/components/AlternatingRows.tsx
Normal file
35
src/ui/components/AlternatingRows.tsx
Normal 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;
|
||||
@@ -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,
|
||||
* and the other will grow automatically
|
||||
*/
|
||||
const HBoxContainer = styled(FlexRow)({
|
||||
const HBoxContainer = styled(FlexRow)(
|
||||
({verticalAlign}: {verticalAlign: string}) => ({
|
||||
shrink: 0,
|
||||
alignItems: 'center',
|
||||
});
|
||||
alignItems: verticalAlign,
|
||||
}),
|
||||
);
|
||||
|
||||
HBoxContainer.displayName = 'HBoxContainer';
|
||||
|
||||
@@ -27,7 +29,8 @@ const HBox: React.FC<{
|
||||
children: [] | [React.ReactNode] | [React.ReactNode, React.ReactNode];
|
||||
grow?: 'left' | 'right' | 'auto';
|
||||
childWidth?: number;
|
||||
}> = ({children, grow, childWidth}) => {
|
||||
verticalAlign?: 'center' | 'top';
|
||||
}> = ({children, grow, childWidth, verticalAlign}) => {
|
||||
if (children.length > 2) {
|
||||
throw new Error('HBox expects at most 2 children');
|
||||
}
|
||||
@@ -45,25 +48,26 @@ const HBox: React.FC<{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
} as const;
|
||||
const vAlign = verticalAlign === 'top' ? 'normal' : 'center';
|
||||
|
||||
switch (grow) {
|
||||
case 'right':
|
||||
return (
|
||||
<HBoxContainer>
|
||||
<HBoxContainer verticalAlign={vAlign}>
|
||||
<div style={{...fixedStyle, marginRight: 8}}>{left}</div>
|
||||
<div style={growStyle}>{right}</div>
|
||||
</HBoxContainer>
|
||||
);
|
||||
case 'left':
|
||||
return (
|
||||
<HBoxContainer>
|
||||
<HBoxContainer verticalAlign={vAlign}>
|
||||
<div style={growStyle}>{left}</div>
|
||||
<div style={{...fixedStyle, marginLeft: 8}}>{right}</div>
|
||||
</HBoxContainer>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<HBoxContainer>
|
||||
<HBoxContainer verticalAlign={vAlign}>
|
||||
<div style={growStyle}>{left}</div>
|
||||
<div style={{...growStyle, marginLeft: 8}}>{right}</div>
|
||||
</HBoxContainer>
|
||||
@@ -73,6 +77,7 @@ const HBox: React.FC<{
|
||||
HBox.defaultProps = {
|
||||
grow: 'right',
|
||||
childWidth: 0,
|
||||
verticalAlign: 'center',
|
||||
};
|
||||
|
||||
HBox.displayName = 'HBox';
|
||||
|
||||
@@ -169,3 +169,4 @@ export {default as RoundedSection} from './components/RoundedSection';
|
||||
export {default as CenteredView} from './components/CenteredView';
|
||||
export {default as Info} from './components/Info';
|
||||
export {default as Bordered} from './components/Bordered';
|
||||
export {default as AlternatingRows} from './components/AlternatingRows';
|
||||
|
||||
Reference in New Issue
Block a user