Skip to content

Commit

Permalink
feat: support dark theme color for search and close icon
Browse files Browse the repository at this point in the history
  • Loading branch information
foray1010 committed Nov 5, 2020
1 parent eb21c83 commit fccb1c1
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 38 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@foray1010/remark-preset": "3.4.0",
"@foray1010/stylelint-config": "2.2.5",
"@foray1010/tsconfig": "3.0.1",
"@svgr/webpack": "5.4.0",
"@testing-library/react": "11.1.0",
"@testing-library/user-event": "12.1.10",
"@types/bluebird": "3.5.33",
Expand Down
10 changes: 8 additions & 2 deletions src/core/types/svg.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
declare module '*.svg' {
const image: string
export default image
import * as React from 'react'

export const ReactComponent: React.FunctionComponent<React.SVGProps<
SVGSVGElement
>>

const src: string
export default src
}
18 changes: 4 additions & 14 deletions src/popup/components/Search/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import * as React from 'react'
import webExtension from 'webextension-polyfill'

import Input from '../../../core/components/baseItems/Input'
import LazyImage from '../../../core/components/baseItems/LazyImage'
import cancelIcon from '../../images/cancel.svg'
import searchIcon from '../../images/search.svg'
import { ReactComponent as Cross } from '../../images/cross.svg'
import { ReactComponent as Search } from '../../images/search.svg'
import classes from './search-input.css'

interface Props extends React.ComponentProps<typeof Input> {
Expand All @@ -15,11 +14,7 @@ const SearchInput = React.forwardRef<HTMLInputElement, Props>(
function InnerSearchInput({ onCancel, ...inputProps }: Props, ref) {
return (
<div className={classes.main}>
<LazyImage
alt='search'
className={classes['search-icon']}
src={searchIcon}
/>
<Search className={classes['search-icon']} />
<Input
ref={ref}
inputMode='search'
Expand All @@ -28,12 +23,7 @@ const SearchInput = React.forwardRef<HTMLInputElement, Props>(
className={classNames(classes['search-input'], inputProps.className)}
/>
{inputProps.value ? (
<LazyImage
alt='clear search'
className={classes['cancel-icon']}
src={cancelIcon}
onClick={onCancel}
/>
<Cross className={classes['cancel-icon']} onClick={onCancel} />
) : null}
</div>
)
Expand Down
14 changes: 8 additions & 6 deletions src/popup/components/Search/search-input.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.cancel-icon {
width: 14px;
height: 14px;
height: 100%;
box-sizing: border-box;
flex-shrink: 0;
padding: 5px;
padding: var(--golden-gap-2x);
color: var(--highlight-level4);
}

.main {
Expand All @@ -14,11 +15,12 @@
}

.search-icon {
width: 14px;
height: 14px;
height: 100%;
box-sizing: border-box;
flex-shrink: 0;
padding: 4px;
padding: var(--golden-gap-2x);
padding-right: 3px;
color: var(--highlight-level4);
}

.search-input {
Expand Down
1 change: 0 additions & 1 deletion src/popup/images/cancel.svg

This file was deleted.

1 change: 1 addition & 0 deletions src/popup/images/cross.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/popup/images/folder.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/popup/images/search.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/popup/reduxs/bookmark/utils/converters.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as R from 'ramda'

import * as CST from '../../../constants'
import folderIcon from '../../../images/folder.svg'
import folderIconUrl from '../../../images/folder.svg'
import type { BookmarkInfo } from '../../../types'

export const getIconUrl = (bookmarkInfo: BookmarkInfo): string => {
if (bookmarkInfo.type === CST.BOOKMARK_TYPES.BOOKMARK)
return `chrome://favicon/${bookmarkInfo.url}`
if (bookmarkInfo.type === CST.BOOKMARK_TYPES.FOLDER) return folderIcon
if (bookmarkInfo.type === CST.BOOKMARK_TYPES.FOLDER) return folderIconUrl
return ''
}

Expand Down
16 changes: 14 additions & 2 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const webpackConfig: webpack.Configuration = {
},
},
{
test: /\.(png|svg)$/,
test: /\.png$/,
loader: 'file-loader',
options: {
name: 'images/[name].[ext]',
Expand All @@ -83,14 +83,26 @@ const webpackConfig: webpack.Configuration = {
...(isDevelopmentBuild
? [
{
test: /\/core\/.+\.(png|svg)$/,
test: /\/core\/.+\.png$/,
loader: 'image-process-loader',
options: {
greyscale: true,
},
},
]
: []),
{
test: /\.svg$/,
use: [
'@svgr/webpack',
{
loader: 'file-loader',
options: {
name: 'images/[name].[ext]',
},
},
],
},
{
test: /\/manifest\.yml$/,
use: [
Expand Down

0 comments on commit fccb1c1

Please sign in to comment.