Skip to content

Commit

Permalink
Merge pull request #372 from markrickert/mrickert/darkMode
Browse files Browse the repository at this point in the history
  • Loading branch information
pvinis authored Dec 4, 2023
2 parents 940a99c + 5b3998a commit 8faec57
Show file tree
Hide file tree
Showing 19 changed files with 416 additions and 202 deletions.
7 changes: 3 additions & 4 deletions src/components/common/BinaryDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ const BinaryRow = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
background-color: ${({ index }) => (index % 2 === 0 ? '#fafbfc' : '#ffffff')};
color: #24292e;
background-color: ${({ index, theme }) =>
index % 2 === 0 ? theme.rowEven : theme.rowOdd};
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier,
monospace;
font-size: 12px;
width: 500px;
max-width: 500px;
padding: 10px 15px;
border-bottom: 1px solid #e1e4e8;
border-bottom: 1px solid ${({ theme }) => theme.border};
`

const Popover = styled(({ className, ...props }) => (
<AntdPopover overlayClassName={className} {...props} />
))`
.ant-popover-inner-content {
padding: 0;
background: red;
}
`

Expand Down
8 changes: 4 additions & 4 deletions src/components/common/CompletedFilesCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ const CompletedFilesCounter = styled(
position: fixed;
bottom: 20px;
right: 20px;
background: #d5eafd;
background: ${({ theme }) => theme.popover.background};
padding: 10px;
border: 1px solid #1890ff;
border: 1px solid ${({ theme }) => theme.popover.border};
border-radius: 20px;
color: #7dadda;
color: ${({ theme }) => theme.popover.text};
transform: ${({ completed }) =>
completed ? 'translateY(0px)' : 'translateY(70px)'};
display: flex;
Expand All @@ -76,7 +76,7 @@ const CompletedFilesCounter = styled(
`}
.completedAmount {
color: #1890ff;
color: ${({ theme }) => theme.popover.border};
}
`

Expand Down
18 changes: 18 additions & 0 deletions src/components/common/DarkModeButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { Button as AntdButton, Tooltip } from 'antd'
import styled from '@emotion/styled'

const Button = styled(AntdButton)`
width: 32px;
padding: 0;
`

const DarkModeButton = ({ isDarkMode, ...props }) => {
return (
<Tooltip placement="bottomLeft" title="Toggle Light/Dark Mode">
<Button {...props}>{isDarkMode ? '🌙' : '☀️'}</Button>
</Tooltip>
)
}

export { DarkModeButton }
101 changes: 81 additions & 20 deletions src/components/common/Diff/Diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ const copyPathPopoverContentOpts = {
}

const Container = styled.div`
border: 1px solid #e8e8e8;
border: 1px solid ${({ theme }) => theme.border};
border-radius: 3px;
margin-bottom: 16px;
margin-top: 16px;
color: ${({ theme }) => theme.text};
`

const More = styled.div`
background-color: #f1f8ff;
margin-left: 30px;
padding-left: 4px;
color: '#1b1f23b3';
`

const Decoration = styled(DiffDecoration)`
background-color: #dbedff;
background-color: ${({ theme }) => theme.diff.decorationContentBackground};
color: ${({ theme }) => theme.diff.decorationContent};
`

const DiffView = styled(RDiff)`
Expand All @@ -44,31 +44,19 @@ const DiffView = styled(RDiff)`
monospace;
}
td.diff-gutter {
color: rgba(27, 31, 35, 0.3);
padding: 0;
text-align: center;
font-size: 12px;
cursor: auto;
}
td.diff-gutter .diff-line-normal {
background-color: #cdffd8;
border-color: #bef5cb;
background-color: ${({ theme }) => theme.gutterInsertBackground};
border-color: ${({ theme }) => theme.greenBorder};
}
td.diff-gutter:hover {
cursor: pointer;
color: rgba(27, 31, 35, 0.6);
color: ${({ theme }) => theme.textHover};
}
td.diff-code {
font-size: 12px;
color: #24292e;
}
td.diff-code-insert .diff-code-edit {
background-color: #acf2bd;
color: ${({ theme }) => theme.text};
}
td.diff-gutter-omit:before {
Expand All @@ -79,6 +67,79 @@ const DiffView = styled(RDiff)`
td.diff-widget-content {
padding: 0;
}
// From diff global
.diff {
background-color: ${({ theme }) => theme.diff.backgroundColor};
color: ${({ theme }) => theme.diff.text};
tab-size: 4;
hyphens: none;
}
.diff::selection {
background-color: ${({ theme }) => theme.diff.selectionMackground};
}
.diff-decoration {
line-height: 2;
font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier,
monospace;
background-color: ${({ theme }) => theme.diff.decorationBackground};
}
.diff-decoration-content {
padding-left: 0.5em;
background-color: ${({ theme }) => theme.diff.contentBackground};
color: ${({ theme }) => theme.diff.decorationContent};
}
.diff-gutter {
padding: 0;
text-align: center;
font-size: 12px;
cursor: auto;
}
.diff-gutter-insert {
background-color: ${({ theme }) => theme.diff.gutterInsertBackground};
}
.diff-gutter-delete {
background-color: ${({ theme }) => theme.diff.gutterDeleteBackground};
}
.diff-gutter-selected {
background-color: ${({ theme }) => theme.diff.gutterSelectedBackground};
}
.diff-code-insert {
background-color: ${({ theme }) => theme.diff.codeInsertBackground};
}
.diff-code-edit {
color: inherit;
}
.diff-code-insert .diff-code-edit {
background-color: ${({ theme }) => theme.diff.codeInsertEditBackground};
}
.diff-code-delete {
background-color: ${({ theme }) => theme.diff.codeDeleteBackground};
}
.diff-code-delete .diff-code-edit {
background-color: ${({ theme }) => theme.diff.codeDeleteEditBackground};
}
.diff-code-selected {
background-color: ${({ theme }) => theme.diff.codeSelectedBackground};
}
.diff-decoration-gutter {
background-color: ${({ theme }) => theme.diff.decorationGutterBackground};
color: ${({ theme }) => theme.diff.decorationGutter};
}
`

// Diff will be collapsed by default if the file has been deleted or has more than 5 hunks
Expand Down
61 changes: 32 additions & 29 deletions src/components/common/Diff/DiffComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,40 @@ import { motion } from 'framer-motion'
import { removeAppPathPrefix, getVersionsContentInDiff } from '../../../utils'
import Markdown from '../Markdown'

const lineColors = {
add: '#d6fedb',
delete: '#fdeff0',
neutral: '#ffffff',
}

const Container = styled(({ isCommentOpen, children, ...props }) => (
<motion.div
{...props}
variants={{
open: {
height: 'auto',
},
hidden: { height: 10 },
}}
initial={isCommentOpen ? 'open' : 'hidden'}
animate={isCommentOpen ? 'open' : 'hidden'}
transition={{
duration: 0.5,
}}
inherit={false}
>
<div children={children} />
</motion.div>
))`
const Container = styled(({ isCommentOpen, children, ...props }) => {
return (
<motion.div
{...props}
variants={{
open: {
height: 'auto',
},
hidden: { height: 10 },
}}
initial={isCommentOpen ? 'open' : 'hidden'}
animate={isCommentOpen ? 'open' : 'hidden'}
transition={{
duration: 0.5,
}}
inherit={false}
>
<div children={children} />
</motion.div>
)
})`
overflow: hidden;
& > div {
display: flex;
flex-direction: row;
background-color: ${({ lineChangeType }) => lineColors[lineChangeType]};
background-color: ${({ lineChangeType, theme }) => {
const colorMap = {
add: theme.diff.codeInsertBackground,
delete: theme.diff.codeDeleteBackground,
}
return colorMap[lineChangeType] || theme.background
}};
cursor: pointer;
}
`
Expand All @@ -43,8 +46,8 @@ const ContentContainer = styled.div`
flex: 1;
position: relative;
padding: 16px;
color: #000;
background-color: #fffbe6;
color: ${({ theme }) => theme.text};
background-color: ${({ theme }) => theme.yellowBackground};}
user-select: none;
`

Expand All @@ -67,7 +70,7 @@ const ShowButton = styled(({ isCommentOpen, ...props }) => (
}}
/>
))`
background-color: #ffe58f;
background-color: ${({ theme }) => theme.yellowBorder};
margin-left: 20px;
width: 10px;
cursor: pointer;
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Diff/DiffCommentReminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const DiffCommentReminder = styled(
}
)`
display: inline;
background-color: #fffbe6;
background-color: ${({ theme }) => theme.yellowBackground};
padding: 5px;
border-radius: 3px;
margin-left: 10px;
border: 1px solid #ffe58f;
border: 1px solid ${({ theme }) => theme.yellowBorder};
& > .icon {
margin-right: 6px;
Expand Down
14 changes: 7 additions & 7 deletions src/components/common/Diff/DiffHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const Wrapper = styled.div`
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier,
monospace;
font-size: 12px;
color: #24292e;
color: ${({ theme }) => theme.text};
line-height: 32px;
background-color: #fafbfc;
border-bottom: 1px solid #e1e4e8;
background-color: ${({ theme }) => theme.background};
border-bottom: 1px solid ${({ theme }) => theme.border};
border-top-left-radius: 2px;
border-top-right-radius: 2px;
padding: 5px 10px;
Expand Down Expand Up @@ -122,8 +122,8 @@ const CompleteDiffButton = styled(({ open, onClick, ...props }) =>
&,
&:hover,
&:focus {
color: ${({ isDiffCompleted }) =>
isDiffCompleted ? '#52c41a' : '#24292e'};
color: ${({ isDiffCompleted, theme }) =>
isDiffCompleted ? '#52c41a' : theme.text};
}
`

Expand Down Expand Up @@ -212,7 +212,7 @@ const CollapseClickableArea = styled.div`
const CollapseDiffButton = styled(({ open, isDiffCollapsed, ...props }) =>
open ? <Button {...props} type="link" icon={<DownOutlined />} /> : null
)`
color: #24292e;
color: ${({ theme }) => theme.text};
margin-right: 2px;
font-size: 10px;
transform: ${({ isDiffCollapsed }) =>
Expand All @@ -223,7 +223,7 @@ const CollapseDiffButton = styled(({ open, isDiffCollapsed, ...props }) =>
height: auto;
&:hover,
&:focus {
color: #24292e;
color: ${({ theme }) => theme.text};
}
`

Expand Down
Loading

0 comments on commit 8faec57

Please sign in to comment.