From fa54ea314f333986e550593c76cca91927a8d19c Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 28 May 2020 14:27:02 +0800 Subject: [PATCH] feat: use octoicon v2 --- package.json | 3 +- src/components/Icon.tsx | 52 +++++++++++++++----------------- src/components/ResizeHandler.tsx | 2 +- src/components/SearchBar.tsx | 4 +-- src/content.scss | 33 +++++++++++--------- yarn.lock | 12 +++----- 6 files changed, 52 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index 96322c9..9cb218f 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,7 @@ "dependencies": { "@primer/components": "^16.0.0", "@primer/css": "^14.2.0", - "@primer/octicons": "^9.2.0", - "@primer/octicons-react": "^9.2.0", + "@primer/octicons-v2-react": "^0.0.0-53e900d", "@sentry/browser": "^5.12.1", "@types/firefox-webext-browser": "^70.0.1", "@types/history": "^4.7.5", diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index ec7ef44..f5e6d4b 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -1,20 +1,20 @@ -import Octicon, { - ChevronDown, - ChevronRight, - File, - FileCode, - FileMedia, - FilePdf, - FileSubmodule as Submodule, - FileZip, - Gear, - Grabber, +import { + ChevronDownIcon as ChevronDown, + ChevronRightIcon as ChevronRight, + FileCodeIcon as FileCode, + FileIcon as File, + FileMediaIcon as FileMedia, + FileSubmoduleIcon as Submodule, + FileZipIcon as FileZip, + GearIcon as Gear, + GrabberIcon as Grabber, Icon as OcticonIcon, - Markdown, - Octoface, - Reply, - X, -} from '@primer/octicons-react' + IconProps, + MarkdownIcon as Markdown, + OctofaceIcon as Octoface, + ReplyIcon as Reply, + XIcon as X, +} from '@primer/octicons-v2-react' import * as React from 'react' import { cx } from 'utils/cx' @@ -65,11 +65,12 @@ function getSVGIconComponent( IconComponent: Reply, name: 'Reply', } - case '.pdf': - return { - IconComponent: FilePdf, - name: 'FilePdf', - } + // not supported in octicon v2 yet + // case '.pdf': + // return { + // IconComponent: FilePdf, + // name: 'FilePdf', + // } case '.zip': case '.rar': case '.7z': @@ -122,18 +123,13 @@ type Props = { className?: string placeholder?: boolean onClick?: (event: React.MouseEvent) => void -} +} & IconProps export function Icon({ type, className = undefined, placeholder, ...otherProps }: Props) { let children: React.ReactNode = null if (!placeholder) { const { name, IconComponent } = getSVGIconComponent(type) - const mergedClassName = cx('octicon', name) - children = React.createElement(Octicon, { - icon: IconComponent, - className: mergedClassName, - verticalAlign: 'text-bottom', - }) + children = } return (
diff --git a/src/components/ResizeHandler.tsx b/src/components/ResizeHandler.tsx index a3b9fd8..70e983a 100644 --- a/src/components/ResizeHandler.tsx +++ b/src/components/ResizeHandler.tsx @@ -47,7 +47,7 @@ export function HorizontalResizeHandler({ onResize, size, style }: Props) { return (
- +
) } diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx index a8d957a..96462e7 100644 --- a/src/components/SearchBar.tsx +++ b/src/components/SearchBar.tsx @@ -1,5 +1,5 @@ import { TextInput } from '@primer/components' -import { Search } from '@primer/octicons-react' +import { SearchIcon } from '@primer/octicons-v2-react' import * as React from 'react' import { cx } from 'utils/cx' import { isValidRegexpSource } from 'utils/general' @@ -15,7 +15,7 @@ export function SearchBar({ onSearch, onFocus, searchKey }: Props) {