aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-tools-pages/ts/components/List.tsx
blob: b9bc4ab248229a58ed06b8a7201c10e665eeaabe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as React from 'react';
import styled from 'styled-components';
import { media } from '../variables';

const StyledList = styled.ul`
    list-style-type: none;
    margin: 0;
    padding-inline-start: 0rem;
    position: relative;
`;

const StyledItem = styled.li`
    position: relative;
    padding-left: 26px;  

    :before {
        content: '';
        position: absolute;
        left: 0;
        border: 1px solid black;
        width: 0.6875rem;
        height: 0.6875rem;
        display: inline-block;
        transform: rotate(45deg) translateY(-50%);
        top: 12px;
    }
    :not(:last-child) {
        margin-bottom: 0.5625rem;

        ${media.small`margin-bottom: 0.375rem`};
    }
`;

interface ListProps {
    items?: Array<string>;
    children?: React.ReactNode;
}

function List(props: ListProps) {
    return (
        <StyledList>
            {props.children !== undefined
                ? props.children
                : props.items.map((bullet, index) => <StyledItem key={index}>{bullet}</StyledItem>)}
        </StyledList>
    );
}

export default List;
export { List, StyledItem as ListItem };