refactor sidebar styles

Summary: Using styled components rather than class names to follow Flipper's guidelines

Reviewed By: jknoxville

Differential Revision: D17419665

fbshipit-source-id: 17e0a3bd9292327a4b34eb4e87e5271af8fa22c7
This commit is contained in:
Daniel Büchele
2019-09-17 10:15:33 -07:00
committed by Facebook Github Bot
parent 108c49f572
commit ada2327520

View File

@@ -5,7 +5,16 @@
* @format * @format
*/ */
import {DetailSidebar, FlexCenter, styled, colors} from 'flipper'; import {
DetailSidebar,
FlexCenter,
styled,
colors,
FlexRow,
FlexColumn,
Text,
Panel,
} from 'flipper';
import {Bookmark, URI} from '../types'; import {Bookmark, URI} from '../types';
import {IconButton} from './'; import {IconButton} from './';
import React from 'react'; import React from 'react';
@@ -26,46 +35,45 @@ const BookmarksList = styled('div')({
overflowX: 'hidden', overflowX: 'hidden',
height: '100%', height: '100%',
backgroundColor: colors.white, backgroundColor: colors.white,
'.bookmark-container': { });
width: '100%',
padding: '10px', const BookmarkContainer = styled(FlexRow)({
cursor: 'pointer', width: '100%',
borderBottom: `1px ${colors.greyTint} solid`, padding: 10,
height: 55,
alignItems: 'center',
cursor: 'pointer',
borderBottom: `1px ${colors.greyTint} solid`,
':last-child': {
borderBottom: '0',
}, },
'.bookmark-container:active': { ':active': {
backgroundColor: colors.highlight, backgroundColor: colors.highlight,
color: colors.white, color: colors.white,
}, },
'.bookmarks-title': { ':active *': {
backgroundColor: colors.light02,
padding: '10px',
borderBottom: `1px ${colors.greyTint} solid`,
fontWeight: 'bold',
},
'.bookmark-common-name': {
fontSize: 14,
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
lineHeight: 1.2,
fontWeight: 'bold',
},
'.bookmark-container:active>.bookmark-uri': {
color: colors.white, color: colors.white,
}, },
'.bookmark-uri': {
fontSize: 10,
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
lineHeight: 1.2,
color: colors.greyTint3,
},
}); });
const DeleteButton = styled('div')({ const BookmarkTitle = styled(Text)({
padding: 10, fontSize: '1.1em',
float: 'right', overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
fontWeight: 500,
});
const BookmarkSubtitle = styled(Text)({
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
color: colors.greyTint3,
marginTop: 4,
});
const TextContainer = styled(FlexColumn)({
justifyContent: 'center',
}); });
const alphabetizeBookmarkCompare = (b1: Bookmark, b2: Bookmark) => { const alphabetizeBookmarkCompare = (b1: Bookmark, b2: Bookmark) => {
@@ -76,16 +84,29 @@ export default (props: Props) => {
const {bookmarks, onNavigate, onRemove} = props; const {bookmarks, onNavigate, onRemove} = props;
return ( return (
<DetailSidebar> <DetailSidebar>
{bookmarks.size === 0 ? ( <Panel heading="Bookmarks" floating={false} padded={false}>
<NoData grow>No Bookmarks</NoData> {bookmarks.size === 0 ? (
) : ( <NoData grow>No Bookmarks</NoData>
<BookmarksList> ) : (
<div className="bookmarks-title">Bookmarks</div> <BookmarksList>
{[...bookmarks.values()] {[...bookmarks.values()]
.sort(alphabetizeBookmarkCompare) .sort(alphabetizeBookmarkCompare)
.map((bookmark, idx) => ( .map((bookmark, idx) => (
<> <BookmarkContainer
<DeleteButton> key={idx}
role="button"
tabIndex={0}
onClick={() => {
onNavigate(bookmark.uri);
}}>
<TextContainer grow>
<BookmarkTitle>
{bookmark.commonName || bookmark.uri}
</BookmarkTitle>
{!bookmark.commonName && (
<BookmarkSubtitle>{bookmark.uri}</BookmarkSubtitle>
)}
</TextContainer>
<IconButton <IconButton
color={colors.macOSTitleBarButtonBackgroundActive} color={colors.macOSTitleBarButtonBackgroundActive}
outline={false} outline={false}
@@ -93,24 +114,11 @@ export default (props: Props) => {
size={16} size={16}
onClick={() => onRemove(bookmark.uri)} onClick={() => onRemove(bookmark.uri)}
/> />
</DeleteButton> </BookmarkContainer>
<div ))}
key={idx} </BookmarksList>
className="bookmark-container" )}
role="button" </Panel>
tabIndex={0}
onClick={() => {
onNavigate(bookmark.uri);
}}>
<div className="bookmark-common-name">
{bookmark.commonName}
</div>
<div className="bookmark-uri">{bookmark.uri}</div>
</div>
</>
))}
</BookmarksList>
)}
</DetailSidebar> </DetailSidebar>
); );
}; };