Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
sangwoo108 committed Sep 28, 2022
1 parent 0dca146 commit 46371b6
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function Clock () {
? null
: t.value), [formatter, now])

return <StyledClock onDoubleClick={toggleClockFormat} >
return <StyledClock onDoubleClick={toggleClockFormat}>
<StyledTime>{formattedTime}</StyledTime>
</StyledClock>
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface StatsItemProps {
counter: string | number
text?: string
description: string
overriddenTextColor?: string
}

/**
Expand All @@ -41,10 +40,10 @@ export interface StatsItemProps {
* @prop {string} text - descriptive text that goes along the stat
* @prop {string} description - describes what the counter is showing
*/
export function StatsItem ({ testId, counter, text, description, overriddenTextColor }: StatsItemProps) {
return <StyledStatsItem data-test-id={testId} overriddenTextColor={overriddenTextColor}>
export function StatsItem ({ testId, counter, text, description }: StatsItemProps) {
return <StyledStatsItem data-test-id={testId}>
<StyledStatsItemCounter>{counter}</StyledStatsItemCounter>
{text && <StyledStatsItemText>{text}</StyledStatsItemText>}
<StyledStatsItemDescription overriddenTextColor={overriddenTextColor}>{description}</StyledStatsItemDescription>
<StyledStatsItemDescription>{description}</StyledStatsItemDescription>
</StyledStatsItem>
}
4 changes: 2 additions & 2 deletions components/brave_new_tab_ui/components/default/stats/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const StyledStatsItemContainer = styled('ul')<{}>`
font-family: inherit;
`

export const StyledStatsItem = styled('li')<{overriddenTextColor?: string}>`
export const StyledStatsItem = styled('li')<{}>`
list-style-type: none;
font-size: inherit;
font-family: inherit;
Expand Down Expand Up @@ -51,7 +51,7 @@ export const StyledStatsItemText = styled('span')<{}>`
letter-spacing: 0;
`

export const StyledStatsItemDescription = styled('div')<{overriddenTextColor?: string}>`
export const StyledStatsItemDescription = styled('div')<{}>`
font-size: 16px;
font-weight: 500;
color: var(--override-readability-color-rgb, #FFFFFF);
Expand Down

This file was deleted.

5 changes: 1 addition & 4 deletions components/brave_new_tab_ui/containers/newTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ class NewTabPage extends React.Component<Props, State> {
window.clearTimeout(this.braveNewsPromptTimerId)
}
window.removeEventListener('resize', this.handleResize.bind(this))

document.documentElement.style.removeProperty('--override-readability-color-rgb')
document.documentElement.style.removeProperty('--override-readability-color')
}

componentDidUpdate (prevProps: Props) {
Expand Down Expand Up @@ -1195,7 +1192,7 @@ class NewTabPage extends React.Component<Props, State> {
widgetTitle={getLocale('statsTitle')}
textDirection={newTabData.textDirection}
menuPosition={'right'}>
<Stats stats={newTabData.stats} />
<Stats stats={newTabData.stats}/>
</GridWidget>
<GridWidget
pref='showClock'
Expand Down
7 changes: 3 additions & 4 deletions components/brave_new_tab_ui/containers/newTab/stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getLocale } from '../../../common/locale'

interface Props {
stats: NewTab.Stats
overriddenTextColor?: string
}

const MILLISECONDS_PER_ITEM = 50
Expand Down Expand Up @@ -89,16 +88,16 @@ export default function Stats (props: Props) {
return <StatsContainer>
<StatsItem
description={getLocale('adsTrackersBlocked')}
counter={adblockCount.toLocaleString()}/>
counter={adblockCount.toLocaleString()} />
{bandwidthSaved &&
<StatsItem
counter={bandwidthSaved.value}
text={getLocale(bandwidthSaved.id)}
description={getLocale('estimatedBandwidthSaved')}/>
description={getLocale('estimatedBandwidthSaved')} />
}
<StatsItem
counter={timeSaved.value}
text={getLocale(timeSaved.id)}
description={getLocale('estimatedTimeSaved')}/>
description={getLocale('estimatedTimeSaved')} />
</StatsContainer>
}
14 changes: 2 additions & 12 deletions components/brave_new_tab_ui/reducers/new_tab_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { setMostVisitedSettings } from '../api/topSites'
import { handleWidgetPrefsChange } from './stack_widget_reducer'
import { NewTabAdsData } from '../api/newTabAdsData'
import { Background } from '../api/background'
import isReadableOnBackground from '../helpers/colorUtil'

let sideEffectState: NewTab.State = storage.load()

Expand Down Expand Up @@ -60,14 +59,8 @@ export const newTabReducer: Reducer<NewTab.State | undefined> = (state: NewTab.S

if (initialDataPayload.wallpaperData) {
let backgroundWallpaper = initialDataPayload.wallpaperData.backgroundWallpaper
if (backgroundWallpaper?.type === 'color') {
if (backgroundWallpaper.random) {
backgroundWallpaper = backgroundAPI.randomColorBackground(backgroundWallpaper.wallpaperColor)
}

if (!isReadableOnBackground(backgroundWallpaper)) {
(backgroundWallpaper as NewTab.ColorBackground).overriddenForegroundColor = '#000000'
}
if (backgroundWallpaper?.type === 'color' && backgroundWallpaper.random) {
backgroundWallpaper = backgroundAPI.randomColorBackground(backgroundWallpaper.wallpaperColor)
}

state = {
Expand Down Expand Up @@ -144,9 +137,6 @@ export const newTabReducer: Reducer<NewTab.State | undefined> = (state: NewTab.S
state.backgroundWallpaper = { type: 'image', wallpaperImageUrl: url }
} else if (color) {
state.backgroundWallpaper = random ? backgroundAPI.randomColorBackground(color) : { type: 'color', wallpaperColor: color, random }
if (!isReadableOnBackground(state.backgroundWallpaper)) {
(state.backgroundWallpaper as NewTab.ColorBackground).overriddenForegroundColor = '#000000'
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const generateWallpapers = function (images: NewTab.BackgroundWallpaper[],
Object.assign(staticImages, {
[image.author]: {
...image,
// wallpaperImageUrl: require('../../../../img/newtab/backgrounds/' + image.wallpaperImageUrl)
wallpaperImageUrl: ''
wallpaperImageUrl: require('../../../../img/newtab/backgrounds/' + image.wallpaperImageUrl)
}
})

Expand Down
1 change: 0 additions & 1 deletion components/definitions/newTab.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ declare namespace NewTab {
type: 'color'
wallpaperColor: string
random?: boolean
overriddenForegroundColor?: string
}

// Backgrounds based on image. Custom image background or Brave background.
Expand Down

0 comments on commit 46371b6

Please sign in to comment.