Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format bar with bold, italic, header, and text buttons #269

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/components/DraftView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ export default function DraftView(props: DraftViewProps) {
display: flex;
flex-direction: column;
row-gap: 10px;
padding: 10px 0px;
padding-top: 10px;
padding-bottom: 30px;
`}
>
<div
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/EditReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ErrorBoundary } from 'react-error-boundary'
import { Author } from 'api'
import { Editor } from './Editor'
import Documents from '../Documents'
import FormatBar from './FormatBar'

let documents = Documents()

Expand Down Expand Up @@ -74,9 +75,12 @@ export function EditReviewView(props: Props) {
border: 1px solid #c6c6c6;
flex: 1 1 auto;
overflow: auto;
display: flex;
flex-direction: column;
`}
onClick={onClick}
>
<FormatBar />
{component}
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const editorSharedCSS = css`

export const textCSS = css`
width: 100%;
height: 100%;
flex: 1 1 auto;
border: none;
resize: none;
font-size: 16px;
Expand Down
50 changes: 50 additions & 0 deletions app/src/components/FormatBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react/macro'
import * as React from 'react'
import { IconButton } from '@mui/material'

import { editorSharedCSS } from './Editor'
import { ReactComponent as Bold } from '../components/icons/format/Bold.svg'
import { ReactComponent as Italic } from '../components/icons/format/Italic.svg'
import { ReactComponent as H1 } from '../components/icons/format/H1.svg'
import { ReactComponent as H2 } from '../components/icons/format/H2.svg'
import { ReactComponent as H3 } from '../components/icons/format/H3.svg'
import { ReactComponent as Text } from '../components/icons/format/Text.svg'

export default function FormatBar() {
return (
<div
css={css`
border-bottom: 1px solid lightgray;
${editorSharedCSS}
padding-top: 2px;
padding-bottom: 2px;
`}
>
<div
css={css`
margin-left: -12px;
`}
>
<IconButton aria-label="bold" title="ctrl-b or cmd+b">
<Bold />
</IconButton>
<IconButton aria-label="italic" title="ctrl-i or cmd-i">
<Italic />
</IconButton>
<IconButton aria-label="heading 1" title="ctrl-alt-1">
<H1 />
</IconButton>
<IconButton aria-label="heading 2" title="ctrl-alt-2">
<H2 />
</IconButton>
<IconButton aria-label="heading 3" title="ctrl-alt-3">
<H3 />
</IconButton>
<IconButton aria-label="text" title="ctrl-alt-0">
<Text />
</IconButton>
</div>
</div>
)
}
3 changes: 3 additions & 0 deletions app/src/components/icons/format/Bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/components/icons/format/H1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/components/icons/format/H2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/components/icons/format/H3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/components/icons/format/Italic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/components/icons/format/Paragraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/components/icons/format/Text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.