Skip to content

Commit

Permalink
feat: add DrawingItem component
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewinci committed Mar 14, 2023
1 parent 2a34c9a commit fb73804
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 28 deletions.
10 changes: 8 additions & 2 deletions src/components/container.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import styled from "@emotion/styled";

export const Group = styled.div`
type GroupProps = {
justifyContent?: "center" | "space-between"
maxHeight?: number;
}

export const Group = styled.div<GroupProps>`
display: flex;
justify-content: center;
justify-content: ${props => (props.justifyContent ?? "center")};
max-height: ${props => props.maxHeight ? `${props.maxHeight}px` : undefined};
`
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./button";
export * from "./title-bar";
export * from "./container";
export * from "./input";
export * from "./text";
17 changes: 17 additions & 0 deletions src/components/text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from "@emotion/styled";

type TextProps = {
size: "xl" | "l" | "s";
margin?: number
}

export const Text = styled.p<TextProps>`
font-size: ${(props) => {
switch (props.size) {
case "xl": return "20px";
case "l": return "10px";
case "s": return "18px";
}
}};
margin: ${props => props.margin ? `${props.margin}px` : 0};
`
55 changes: 29 additions & 26 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
// entry point of the react app that powers the extension pop-up
import { Global } from '@emotion/react'
import { css, Global } from '@emotion/react'
import styled from '@emotion/styled'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { Button, Group, Input, TitleBar } from './components'
import { Button, Group, Input, TitleBar, Text } from './components'
import { GlobalStyles } from './style'

const DrawingItem = ({ name, date }: { name: string, date: string }) => {
const ItemContainer = styled.div`
border: 1px solid black;
padding: 0px 10px;
`;
return <ItemContainer>
<Text margin={10} size='s'>{name}</Text>
<Group justifyContent="space-between">
<Group maxHeight={30}>
<Button>Open</Button>
<Button>Update</Button>
<Button>Bin it</Button>
</Group>
<Text size='s' margin={5}>{date}</Text>
</Group>
</ItemContainer>
}

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<Global styles={GlobalStyles} />
Expand All @@ -17,30 +36,14 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<h2 style={{ fontSize: "23px", marginBottom: "5px" }}>My drawings</h2>
</Group>
<div style={{ maxHeight: "245px", minHeight: "245px", overflow: "scroll", border: "2px solid black", borderRadius: "4px" }}>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<Group>
<h3 style={{ fontSize: "23px" }}>Drawing 1</h3>
</Group>
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
<DrawingItem name="My awesome drawing" date='01/01/2023' />
</div>

</React.StrictMode>,
Expand Down

0 comments on commit fb73804

Please sign in to comment.