From fdaef3a9f7d16c55e51fc2ecefa7fbdae799b960 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 16 Dec 2017 11:41:10 +0000 Subject: [PATCH] Make our List widget more like the mui one. --- src/List.css | 67 +++++++++++++++++++++++++++++++++++++++-- src/List.tsx | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 147 insertions(+), 4 deletions(-) diff --git a/src/List.css b/src/List.css index 80f489d..3aa69fa 100644 --- a/src/List.css +++ b/src/List.css @@ -1,14 +1,77 @@ .List { list-style: none; padding: 0; + margin: 0; } .ListItem { - padding: 10px; + padding: 0 10px; + display: flex; + align-items: center; + height: 60px; } -.ListItem:hover { +.ListItem-href { + display: flex; + align-items: center; + width: 100%; + height: 100%; + + color: black; + text-decoration: none; + border: none; +} + +.ListItem-href:visited, .ListItem-href:active, .ListItem-href:focus { + color: inherit; + outline: 0; +} + +.ListItem .ListIcon { + margin-left: 5px; + margin-right: 20px; + margin-top: 8px; + margin-bottom: 8px; +} + +.ListItem-Item:hover { background-color: rgba(0, 0, 0, 0.1); cursor: pointer; } +.ListItem-inset { + margin-left: 49px; +} + +.ListItem-nested-holder { + margin-left: 20px; +} + +.ListItem-text-holder { + display: flex; + flex-direction: column; +} + +.ListItem-primary-text { +} + +.ListItem-secondary-text { + margin-top: 1px; + font-size: 85%; + color: rgba(0, 0, 0, 0.54); +} + +.ListSubheader { + font-size: 90%; + color: rgba(0, 0, 0, 0.54); +} + +.ListDivider { + height: 1px; + border: medium none; + background-color: rgb(224, 224, 224); +} + +.ListDivider.ListDivider-inset { + margin-left: 59px; +} diff --git a/src/List.tsx b/src/List.tsx index f893a91..28be009 100644 --- a/src/List.tsx +++ b/src/List.tsx @@ -3,15 +3,95 @@ import { pure } from 'recompose'; import './List.css'; -export const ListItem = pure((props: any) => ( +export const ListItemRaw = pure((_props: any) => { + const { + href, + children, + nestedItems, + insetChildren, + ...props + } = _props; + + const inner = href ? + ( + + {children} + + ) : + children + ; + + const nestedContent = nestedItems ? + ( + + {nestedItems} + + ) : + undefined + ; + + return ( + +
  • + {inner} +
  • +
  • + {nestedContent} +
  • +
    + ); +}); + +export const ListSubheader = pure((props: any) => (
  • {props.children}
  • )); +export const ListDivider = pure((props: any) => ( +
    +)); + +export const ListItem = pure((_props: any) => { + const { + leftIcon, + primaryText, + secondaryText, + children, + ...props + } = _props; + + const leftIconHolder = (leftIcon) ? ( +
    {leftIcon}
    + ) : undefined; + + let textHolder = primaryText; + if (secondaryText) { + textHolder = ( +
    + {primaryText} + {secondaryText} +
    + ); + } + + return ( + + {leftIconHolder} + {textHolder} + {children} + + ); +}); + export const List = pure((props: { children: React.ReactNode[] | React.ReactNode }) => (