refactor(app): switch to @phosphor-icons/core and format files
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,vue}\""
|
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,vue}\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@phosphor-icons/core": "^1.4.5",
|
||||||
"file-saver": "^2.0.2",
|
"file-saver": "^2.0.2",
|
||||||
"framer-motion": "^3.10.0",
|
"framer-motion": "^3.10.0",
|
||||||
"fuse.js": "^6.4.1",
|
"fuse.js": "^6.4.1",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React from "react";
|
||||||
import { render } from '@testing-library/react';
|
import { render } from "@testing-library/react";
|
||||||
import App from './App';
|
import App from "./App";
|
||||||
|
|
||||||
test('renders learn react link', () => {
|
test("renders learn react link", () => {
|
||||||
const { getByText } = render(<App />);
|
const { getByText } = render(<App />);
|
||||||
const linkElement = getByText(/learn react/i);
|
const linkElement = getByText(/learn react/i);
|
||||||
expect(linkElement).toBeInTheDocument();
|
expect(linkElement).toBeInTheDocument();
|
||||||
|
|||||||
@@ -5,13 +5,16 @@ interface ErrorBoundaryProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ErrorBoundaryState {
|
interface ErrorBoundaryState {
|
||||||
errorMessage?: string
|
errorMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
export default class ErrorBoundary extends React.Component<
|
||||||
|
ErrorBoundaryProps,
|
||||||
|
ErrorBoundaryState
|
||||||
|
> {
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { errorMessage: "" }
|
this.state = { errorMessage: "" };
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromError(error: any) {
|
static getDerivedStateFromError(error: any) {
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ const Footer: React.FC<FooterProps> = () => {
|
|||||||
a little quirky, too.
|
a little quirky, too.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
We're thankful for the tools we've benefited from and
|
We're thankful for the tools we've benefited from and this is our
|
||||||
this is our contribution towards a collaborative community.
|
contribution towards a collaborative community.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Phosphor is free and open-source, licensed under{" "}
|
Phosphor is free and open-source, licensed under{" "}
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ interface NoticeProps {
|
|||||||
type?: "wait" | "help" | "warn" | "none";
|
type?: "wait" | "help" | "warn" | "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
const Notice: React.FC<NoticeProps> = ({ message, type = "warn", children }) => {
|
const Notice: React.FC<NoticeProps> = ({
|
||||||
|
message,
|
||||||
|
type = "warn",
|
||||||
|
children,
|
||||||
|
}) => {
|
||||||
const isDark = useRecoilValue(isDarkThemeSelector);
|
const isDark = useRecoilValue(isDarkThemeSelector);
|
||||||
const query = useRecoilValue(searchQueryAtom);
|
const query = useRecoilValue(searchQueryAtom);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ type SearchInputProps = {};
|
|||||||
const SearchInput: React.FC<SearchInputProps> = () => {
|
const SearchInput: React.FC<SearchInputProps> = () => {
|
||||||
const [value, setValue] = useState<string>("");
|
const [value, setValue] = useState<string>("");
|
||||||
const [query, setQuery] = useRecoilState(searchQueryAtom);
|
const [query, setQuery] = useRecoilState(searchQueryAtom);
|
||||||
const inputRef = useRef<HTMLInputElement>() as MutableRefObject<HTMLInputElement>;
|
const inputRef =
|
||||||
|
useRef<HTMLInputElement>() as MutableRefObject<HTMLInputElement>;
|
||||||
|
|
||||||
useHotkeys("ctrl+k,cmd+k", (e) => {
|
useHotkeys("ctrl+k,cmd+k", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import React, { useMemo } from "react";
|
|||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import Select from "react-dropdown-select";
|
import Select from "react-dropdown-select";
|
||||||
import { PencilLine } from "phosphor-react";
|
import { PencilLine } from "phosphor-react";
|
||||||
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
|
|
||||||
import { iconWeightAtom } from "../../state/atoms";
|
import { iconWeightAtom } from "../../state/atoms";
|
||||||
import { IconStyle } from "../../lib";
|
|
||||||
import "./StyleInput.css";
|
import "./StyleInput.css";
|
||||||
|
|
||||||
type WeightOption = { key: string; value: IconStyle; icon: JSX.Element };
|
type WeightOption = { key: string; value: IconStyle; icon: JSX.Element };
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import { useEffect } from "react";
|
|||||||
import { useSearchParam } from "react-use";
|
import { useSearchParam } from "react-use";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
import TinyColor from "tinycolor2";
|
import TinyColor from "tinycolor2";
|
||||||
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
|
|
||||||
import { iconColorAtom, iconWeightAtom, iconSizeAtom } from "../state/atoms";
|
import { iconColorAtom, iconWeightAtom, iconSizeAtom } from "../state/atoms";
|
||||||
import { IconStyle } from "../lib";
|
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const weight = useSearchParam("weight")?.replace(/["']/g, "");
|
const weight = useSearchParam("weight")?.replace(/["']/g, "");
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useTimeoutFn } from "react-use";
|
import { useTimeoutFn } from "react-use";
|
||||||
|
|
||||||
export default <T>(baseState: T, ms: number = 1000): [T, (transientValue: T) => void] => {
|
export default <T>(
|
||||||
|
baseState: T,
|
||||||
|
ms: number = 1000
|
||||||
|
): [T, (transientValue: T) => void] => {
|
||||||
const [value, setValue] = useState<T>(baseState);
|
const [value, setValue] = useState<T>(baseState);
|
||||||
const [, cancel, restart] = useTimeoutFn(() => setValue(baseState), ms);
|
const [, cancel, restart] = useTimeoutFn(() => setValue(baseState), ms);
|
||||||
|
|
||||||
|
|||||||
10360
src/lib/icons.ts
10360
src/lib/icons.ts
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,5 @@
|
|||||||
import { Icon } from "phosphor-react";
|
import { Icon } from "phosphor-react";
|
||||||
|
import { IconCategory } from "@phosphor-icons/core";
|
||||||
export enum IconStyle {
|
|
||||||
THIN = "thin",
|
|
||||||
LIGHT = "light",
|
|
||||||
REGULAR = "regular",
|
|
||||||
BOLD = "bold",
|
|
||||||
FILL = "fill",
|
|
||||||
DUOTONE = "duotone",
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum IconCategory {
|
|
||||||
ARROWS = "arrows",
|
|
||||||
BRAND = "brands",
|
|
||||||
COMMERCE = "commerce",
|
|
||||||
COMMUNICATION = "communications",
|
|
||||||
DESIGN = "design",
|
|
||||||
DEVELOPMENT = "technology & development",
|
|
||||||
OFFICE = "office",
|
|
||||||
EDITOR = "editor",
|
|
||||||
FINANCE = "finances",
|
|
||||||
GAMES = "games",
|
|
||||||
HEALTH = "health & wellness",
|
|
||||||
MAP = "maps & travel",
|
|
||||||
MEDIA = "media",
|
|
||||||
NATURE = "nature",
|
|
||||||
OBJECTS = "objects",
|
|
||||||
PEOPLE = "people",
|
|
||||||
SYSTEM = "system",
|
|
||||||
WEATHER = "weather",
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IconEntry {
|
export interface IconEntry {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// opt-in, read https://bit.ly/CRA-PWA
|
// opt-in, read https://bit.ly/CRA-PWA
|
||||||
|
|
||||||
const isLocalhost = Boolean(
|
const isLocalhost = Boolean(
|
||||||
window.location.hostname === 'localhost' ||
|
window.location.hostname === "localhost" ||
|
||||||
// [::1] is the IPv6 localhost address.
|
// [::1] is the IPv6 localhost address.
|
||||||
window.location.hostname === '[::1]' ||
|
window.location.hostname === "[::1]" ||
|
||||||
// 127.0.0.0/8 are considered localhost for IPv4.
|
// 127.0.0.0/8 are considered localhost for IPv4.
|
||||||
window.location.hostname.match(
|
window.location.hostname.match(
|
||||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||||
@@ -26,12 +26,9 @@ type Config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function register(config?: Config) {
|
export function register(config?: Config) {
|
||||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
|
||||||
// The URL constructor is available in all browsers that support SW.
|
// The URL constructor is available in all browsers that support SW.
|
||||||
const publicUrl = new URL(
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||||
process.env.PUBLIC_URL,
|
|
||||||
window.location.href
|
|
||||||
);
|
|
||||||
if (publicUrl.origin !== window.location.origin) {
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||||
// from what our page is served on. This might happen if a CDN is used to
|
// from what our page is served on. This might happen if a CDN is used to
|
||||||
@@ -39,7 +36,7 @@ export function register(config?: Config) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener("load", () => {
|
||||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
if (isLocalhost) {
|
if (isLocalhost) {
|
||||||
@@ -50,8 +47,8 @@ export function register(config?: Config) {
|
|||||||
// service worker/PWA documentation.
|
// service worker/PWA documentation.
|
||||||
navigator.serviceWorker.ready.then(() => {
|
navigator.serviceWorker.ready.then(() => {
|
||||||
console.log(
|
console.log(
|
||||||
'This web app is being served cache-first by a service ' +
|
"This web app is being served cache-first by a service " +
|
||||||
'worker. To learn more, visit https://bit.ly/CRA-PWA'
|
"worker. To learn more, visit https://bit.ly/CRA-PWA"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -65,21 +62,21 @@ export function register(config?: Config) {
|
|||||||
function registerValidSW(swUrl: string, config?: Config) {
|
function registerValidSW(swUrl: string, config?: Config) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register(swUrl)
|
.register(swUrl)
|
||||||
.then(registration => {
|
.then((registration) => {
|
||||||
registration.onupdatefound = () => {
|
registration.onupdatefound = () => {
|
||||||
const installingWorker = registration.installing;
|
const installingWorker = registration.installing;
|
||||||
if (installingWorker == null) {
|
if (installingWorker == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
installingWorker.onstatechange = () => {
|
installingWorker.onstatechange = () => {
|
||||||
if (installingWorker.state === 'installed') {
|
if (installingWorker.state === "installed") {
|
||||||
if (navigator.serviceWorker.controller) {
|
if (navigator.serviceWorker.controller) {
|
||||||
// At this point, the updated precached content has been fetched,
|
// At this point, the updated precached content has been fetched,
|
||||||
// but the previous service worker will still serve the older
|
// but the previous service worker will still serve the older
|
||||||
// content until all client tabs are closed.
|
// content until all client tabs are closed.
|
||||||
console.log(
|
console.log(
|
||||||
'New content is available and will be used when all ' +
|
"New content is available and will be used when all " +
|
||||||
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
|
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
|
||||||
);
|
);
|
||||||
|
|
||||||
// Execute callback
|
// Execute callback
|
||||||
@@ -90,7 +87,7 @@ function registerValidSW(swUrl: string, config?: Config) {
|
|||||||
// At this point, everything has been precached.
|
// At this point, everything has been precached.
|
||||||
// It's the perfect time to display a
|
// It's the perfect time to display a
|
||||||
// "Content is cached for offline use." message.
|
// "Content is cached for offline use." message.
|
||||||
console.log('Content is cached for offline use.');
|
console.log("Content is cached for offline use.");
|
||||||
|
|
||||||
// Execute callback
|
// Execute callback
|
||||||
if (config && config.onSuccess) {
|
if (config && config.onSuccess) {
|
||||||
@@ -101,25 +98,25 @@ function registerValidSW(swUrl: string, config?: Config) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
console.error('Error during service worker registration:', error);
|
console.error("Error during service worker registration:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkValidServiceWorker(swUrl: string, config?: Config) {
|
function checkValidServiceWorker(swUrl: string, config?: Config) {
|
||||||
// Check if the service worker can be found. If it can't reload the page.
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
fetch(swUrl, {
|
fetch(swUrl, {
|
||||||
headers: { 'Service-Worker': 'script' }
|
headers: { "Service-Worker": "script" },
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then((response) => {
|
||||||
// Ensure service worker exists, and that we really are getting a JS file.
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
const contentType = response.headers.get('content-type');
|
const contentType = response.headers.get("content-type");
|
||||||
if (
|
if (
|
||||||
response.status === 404 ||
|
response.status === 404 ||
|
||||||
(contentType != null && contentType.indexOf('javascript') === -1)
|
(contentType != null && contentType.indexOf("javascript") === -1)
|
||||||
) {
|
) {
|
||||||
// No service worker found. Probably a different app. Reload the page.
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
navigator.serviceWorker.ready.then(registration => {
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
registration.unregister().then(() => {
|
registration.unregister().then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
@@ -131,18 +128,18 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.log(
|
console.log(
|
||||||
'No internet connection found. App is running in offline mode.'
|
"No internet connection found. App is running in offline mode."
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unregister() {
|
export function unregister() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.ready
|
navigator.serviceWorker.ready
|
||||||
.then(registration => {
|
.then((registration) => {
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
// allows you to do things like:
|
// allows you to do things like:
|
||||||
// expect(element).toHaveTextContent(/react/i)
|
// expect(element).toHaveTextContent(/react/i)
|
||||||
// learn more: https://github.com/testing-library/jest-dom
|
// learn more: https://github.com/testing-library/jest-dom
|
||||||
import '@testing-library/jest-dom/extend-expect';
|
import "@testing-library/jest-dom/extend-expect";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { atom } from "recoil";
|
import { atom } from "recoil";
|
||||||
import { IconStyle } from "../lib";
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
|
|
||||||
export const searchQueryAtom = atom<string>({
|
export const searchQueryAtom = atom<string>({
|
||||||
key: "searchQueryAtom",
|
key: "searchQueryAtom",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { selector, selectorFamily } from "recoil";
|
import { selector, selectorFamily } from "recoil";
|
||||||
import TinyColor from "tinycolor2";
|
import TinyColor from "tinycolor2";
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
|
import { IconCategory } from "@phosphor-icons/core";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
searchQueryAtom,
|
searchQueryAtom,
|
||||||
@@ -8,7 +9,7 @@ import {
|
|||||||
iconSizeAtom,
|
iconSizeAtom,
|
||||||
iconColorAtom,
|
iconColorAtom,
|
||||||
} from "./atoms";
|
} from "./atoms";
|
||||||
import { IconEntry, IconCategory } from "../lib";
|
import { IconEntry } from "../lib";
|
||||||
import { icons } from "../lib/icons";
|
import { icons } from "../lib/icons";
|
||||||
|
|
||||||
const fuse = new Fuse(icons, {
|
const fuse = new Fuse(icons, {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { SnippetType, IconStyle } from "../lib";
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
|
|
||||||
|
import { SnippetType } from "../lib";
|
||||||
|
|
||||||
export function getCodeSnippets({
|
export function getCodeSnippets({
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user