Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ae59ff810 | ||
|
|
b8f451dc72 | ||
|
|
7b8d4a3010 | ||
|
|
e6b0545194 | ||
|
|
188e3e88a6 | ||
|
|
e865fb2aca | ||
|
|
ceef226e26 | ||
|
|
ea81b78da1 | ||
|
|
697c6c836c | ||
|
|
7502b8b3ce | ||
|
|
383d13c74f | ||
|
|
a21d0de274 | ||
|
|
bce8d12220 | ||
|
|
83b2a59caf | ||
|
|
d8b3ab0279 | ||
|
|
97af564c15 | ||
|
|
aff7abbae6 | ||
|
|
b9e41ac135 | ||
|
|
6db9a08f7f | ||
|
|
2bcf098d1d | ||
|
|
a147070599 | ||
|
|
d209baff11 | ||
|
|
6c636dbebf | ||
|
|
c5def36879 | ||
|
|
07e480c7b7 | ||
|
|
fe7b098f9f | ||
|
|
5c1f41e2fc | ||
|
|
6a27ced40e | ||
|
|
c774c8047a | ||
|
|
24112a8361 | ||
|
|
358ad08165 | ||
|
|
582a9e2fd5 | ||
|
|
07e27cb0f9 | ||
|
|
2fc3263cdc | ||
|
|
4aede2d5d2 | ||
|
|
b1b9eadc35 | ||
|
|
e87c0da9da | ||
|
|
cf1a5c640b |
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
github: [phosphor-icons, rektdeckard]
|
||||||
|
patreon: phosphoricons
|
||||||
|
custom: ["https://www.buymeacoffee.com/phosphoricons"]
|
||||||
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,38 +1,40 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Create a report to help us improve
|
about: Create a report to help us improve
|
||||||
title: ''
|
title: ""
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: rektdeckard
|
assignees: rektdeckard
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Describe the bug**
|
<!-- BEFORE YOU REPORT -->
|
||||||
A clear and concise description of what the bug is.
|
<!-- 1. Search for existing issues! If the issue has already been reported, add a 👍 or a comment to help show your interest. -->
|
||||||
|
<!-- 2. If your issue pertains to a specific library, please leave it on the relevant repository! -->
|
||||||
|
|
||||||
**To Reproduce**
|
**Describe the bug**
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
<!-- A clear and concise description of what the bug is. -->
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
**Steps to Reproduce**
|
||||||
4. See error
|
|
||||||
|
<!-- Steps to reproduce the behavior. -->
|
||||||
|
|
||||||
**Expected behavior**
|
**Expected behavior**
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
<!-- A clear and concise description of what you expected to happen. -->
|
||||||
|
|
||||||
**Screenshots**
|
**Screenshots**
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
<!-- If applicable, add screenshots to help explain your problem. -->
|
||||||
- OS: [e.g. iOS]
|
|
||||||
- Browser [e.g. chrome, safari]
|
|
||||||
- Version [e.g. 22]
|
|
||||||
|
|
||||||
**Smartphone (please complete the following information):**
|
**Context (please complete the following information):**
|
||||||
- Device: [e.g. iPhone6]
|
|
||||||
- OS: [e.g. iOS8.1]
|
|
||||||
- Browser [e.g. stock browser, safari]
|
|
||||||
- Version [e.g. 22]
|
|
||||||
|
|
||||||
**Additional context**
|
<!--
|
||||||
Add any other context about the problem here.
|
- OS: [e.g. Windows 10]
|
||||||
|
- Browser/Environment [e.g. chrome, safari, node]
|
||||||
|
- Library [e.g. @phosphor-icons/react]
|
||||||
|
- Version [e.g. 2.1.0]
|
||||||
|
-->
|
||||||
|
|
||||||
|
**Additional notes**
|
||||||
|
|
||||||
|
<!-- Add any other context about the problem here. -->
|
||||||
|
|||||||
25
.github/ISSUE_TEMPLATE/icon_request.md
vendored
25
.github/ISSUE_TEMPLATE/icon_request.md
vendored
@@ -1,17 +1,24 @@
|
|||||||
---
|
---
|
||||||
name: Icon request
|
name: Icon request
|
||||||
about: Request an icon you'd like to see added
|
about: Request one or more related icons you'd like to see added to our set
|
||||||
title: ''
|
title: ""
|
||||||
labels: enhancement
|
labels: icon
|
||||||
assignees: rektdeckard
|
assignees: rektdeckard
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Describe the requested icon**
|
<!-- BEFORE YOU REQUEST -->
|
||||||
Explain the icon you'd like to see, and potential use-cases.
|
<!-- 1. Search for existing issues! If the icon has already been requested, add a 👍 or a comment to help show your interest. -->
|
||||||
|
<!-- 2. If requesting a brand icon, check this discussion to see if it meets the criteria: https://github.com/orgs/phosphor-icons/discussions/392 -->
|
||||||
|
<!-- 3. If requesting a visual change to an existing icon, make sure it is based on clarity, consistency, or readability -->
|
||||||
|
|
||||||
**Screenshots**
|
**Describe the requested icon(s)**
|
||||||
If applicable, add screenshots to help illustrate the icon appearance.
|
|
||||||
|
<!-- Explain the icon(s) you'd like to see, and potential use-cases. Be specific. Do not say "etc..." unless it is unambiguous what that means. -->
|
||||||
|
|
||||||
|
**References**
|
||||||
|
|
||||||
|
<!-- If applicable, add screenshots, examples, or references to the icon(s) in other sets. -->
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context here.
|
|
||||||
|
<!-- Add any other context here. -->
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -19,7 +19,4 @@
|
|||||||
.env.test.local
|
.env.test.local
|
||||||
.env.production.local
|
.env.production.local
|
||||||
|
|
||||||
npm-debug.log*
|
*.log
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
yarn.lock
|
|
||||||
|
|||||||
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
arrowParens: "always"
|
||||||
|
endOfLine: "auto"
|
||||||
|
bracketSpacing: true
|
||||||
|
printWidth: 80
|
||||||
|
semi: true
|
||||||
|
singleQuote: false
|
||||||
|
tabWidth: 2
|
||||||
|
trailingComma: "es5"
|
||||||
183
CONTRIBUTING.md
Normal file
183
CONTRIBUTING.md
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
# Contributing to Phosphor Icons
|
||||||
|
|
||||||
|
First off, thanks for taking the time to contribute! ❤️
|
||||||
|
|
||||||
|
We welcome many forms of contributions, though due to the creative nature of the project we do not typically accept icon contributions. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them, and read the relevant guidance before making your contribution. We look forward to your input!
|
||||||
|
|
||||||
|
> If you like the project, but don't have time to contribute, there are other easy ways to support the project and show your appreciation:
|
||||||
|
>
|
||||||
|
> - Donate via [Buy Me a Coffee](https://www.buymeacoffee.com/phosphoricons), or become a recurring contributor via [Patreon](https://patreon.com/phosphoricons) (this really helps!)
|
||||||
|
> - Star the project
|
||||||
|
> - Tweet about it, or share on other platforms
|
||||||
|
> - Refer this project in your project's README
|
||||||
|
> - Mention the project at local meetups and tell your friends/colleagues
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
- [I Have a Question](#i-have-a-question)
|
||||||
|
- [I Want To Contribute](#i-want-to-contribute)
|
||||||
|
- [Requesting Icons](#requesting-icons)
|
||||||
|
- [Reporting Bugs](#reporting-bugs)
|
||||||
|
- [Suggesting Enhancements](#suggesting-enhancements)
|
||||||
|
- [Your First Code Contribution](#your-first-code-contribution)
|
||||||
|
- [Improving The Documentation](#improving-the-documentation)
|
||||||
|
- [Styleguides](#styleguides)
|
||||||
|
- [Commit Messages](#commit-messages)
|
||||||
|
- [Join The Project Team](#join-the-project-team)
|
||||||
|
|
||||||
|
## I Have a Question
|
||||||
|
|
||||||
|
> If you want to ask a question, we assume that you have read the available [documentation](https://github.com/phosphor-icons/homepage/blob/master/README.md).
|
||||||
|
|
||||||
|
Before you ask a question, it is best to search for existing [issues](https://github.com/phosphor-icons/homepage/issues) that might help you. In case you have found a suitable issue and still need clarification, you can add your question as a comment in that issue. It is also advisable to search the internet for answers first.
|
||||||
|
|
||||||
|
If you then still feel the need to ask a question and need clarification, we recommend the following:
|
||||||
|
|
||||||
|
- Open a new issue using an [issue template](https://github.com/phosphor-icons/homepage/issues/new/choose).
|
||||||
|
- Provide as much context as you can about what you're running into (the template has prompts to help you here).
|
||||||
|
- Provide project and platform versions (`nodejs`, `npm`, etc), depending on what seems relevant.
|
||||||
|
|
||||||
|
We will address the issue as soon as we can.
|
||||||
|
|
||||||
|
## I Want To Contribute
|
||||||
|
|
||||||
|
> ### Legal Notice <!-- omit in toc -->
|
||||||
|
>
|
||||||
|
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
|
||||||
|
|
||||||
|
### Requesting Icons
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
#### Before Submitting an Icon Request
|
||||||
|
|
||||||
|
- Make sure there is not already an existing request for the icon(s) in question by searching the [issues](https://github.com/phosphor-icons/homepage/issues?q=label%3Aicon).
|
||||||
|
- If requesting a brand icon or logo, read the discussion [regarding brand logos](https://github.com/orgs/phosphor-icons/discussions/392) first, and be sure the brand meets the criteria and scope for this project.
|
||||||
|
- If requesting a visual change to an existing icon, make sure it is based on clarity, consistency, or readability.
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
#### How Do I Submit a Good Icon Request?
|
||||||
|
|
||||||
|
We use GitHub issues to track bicon requests. In order to submit a good icon request:
|
||||||
|
|
||||||
|
- Open an [issue](https://github.com/phosphor-icons/homepage/issues/new?assignees=rektdeckard&labels=icon&projects=&template=icon_request.md&title=).
|
||||||
|
- Include potential use-cases, and any alternatives in the set and why they are insufficient.
|
||||||
|
- Be specific. If requesting multiple icons, do not use "etc." unless it is unambiguous what that means.
|
||||||
|
- If applicabable, add the following supporting information:
|
||||||
|
- Screenshots of related icons in-situ
|
||||||
|
- Examples from other sets
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
### Reporting Bugs
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
#### Before Submitting a Bug Report
|
||||||
|
|
||||||
|
A good bug report contains all the necessary information for us (or others in the community) to reproduce, diagnose, and fix it. We ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
|
||||||
|
|
||||||
|
- If your issue pertains to a specific library, please leave it on the relevant repository.
|
||||||
|
- Make sure that you are using the latest version.
|
||||||
|
- Determine if your bug is really a bug and not an error on your side, e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/phosphor-icons/homepage/blob/master/README.md). If you are looking for support, you might want to check [this section](#i-have-a-question)).
|
||||||
|
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [issue tracker](https://github.com/phosphor-icons/homepage/issues?q=label%3Abug).
|
||||||
|
- Also make sure to search elsewhere (including Stack Overflow, framework or environment docs) to see if users outside of the GitHub community have discussed the issue.
|
||||||
|
- Collect information about the bug:
|
||||||
|
- Stack trace (Traceback)
|
||||||
|
- OS, Platform and Version
|
||||||
|
- Version of the browser, runtime environment, package manager, depending on what seems relevant.
|
||||||
|
- Your input, code, and any other relevant context
|
||||||
|
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
#### How Do I Submit a Good Bug Report?
|
||||||
|
|
||||||
|
> Please do not report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs can be sent by email to [hello@phosphoricons.com](mailto:hello@phosphoricons.com?cc=friedtm@gmail.com&subject=Phosphor%20Security%20Vulnerability).
|
||||||
|
|
||||||
|
<!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->
|
||||||
|
|
||||||
|
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
|
||||||
|
|
||||||
|
- Open an [issue](https://github.com/phosphor-icons/homepage/issues/new?assignees=rektdeckard&labels=bug&projects=&template=bug_report.md&title=).
|
||||||
|
- Fill in the templated fields, making sure to:
|
||||||
|
- Explain the behavior you would expect and the actual behavior.
|
||||||
|
- Provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
|
||||||
|
- Provide the information you collected in the previous section.
|
||||||
|
|
||||||
|
Once it's filed:
|
||||||
|
|
||||||
|
- The project team will label the issue accordingly.
|
||||||
|
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
|
||||||
|
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
|
||||||
|
|
||||||
|
<!-- You might want to create an issue template for bugs and errors that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->
|
||||||
|
|
||||||
|
### Suggesting Enhancements
|
||||||
|
|
||||||
|
This section guides you through submitting an enhancement suggestion for Phosphor Icons, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
#### Before Submitting an Enhancement
|
||||||
|
|
||||||
|
- Make sure that you are using the latest version.
|
||||||
|
- Read the [documentation](https://github.com/phosphor-icons/homepage/blob/master/README.md) carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
||||||
|
- Search the [issues](https://github.com/phosphor-icons/homepage/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
||||||
|
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
#### How Do I Submit a Good Enhancement Suggestion?
|
||||||
|
|
||||||
|
Enhancement suggestions are tracked as [issues](https://github.com/phosphor-icons/homepage/issues).
|
||||||
|
|
||||||
|
- Use a **clear and descriptive title** for the issue to identify the suggestion.
|
||||||
|
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
|
||||||
|
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
|
||||||
|
- You may want to **include screenshots and/or animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to.
|
||||||
|
- **Explain why this enhancement would be useful** to most Phosphor Icons users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
|
||||||
|
|
||||||
|
<!-- ### Your First Code Contribution -->
|
||||||
|
|
||||||
|
<!-- TODO
|
||||||
|
include Setup of env, IDE and typical getting started instructions?
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- ### Improving The Documentation -->
|
||||||
|
|
||||||
|
<!-- If you see something that can be improved in our documentation, -->
|
||||||
|
|
||||||
|
## Styleguides
|
||||||
|
|
||||||
|
### Code Conventions
|
||||||
|
|
||||||
|
We use 80-character print width, 2-space tab width, ES5 trailing commas, double-quoted strings, and trailing semicolons. Please run the format script on all code contributions before submitting a PR:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm format
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commit Messages
|
||||||
|
|
||||||
|
We aspire to use [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#specification) style commit messages. This means commits should be of the format `<noun>(<domain>): <message>`, where:
|
||||||
|
|
||||||
|
- `<noun>` is one of `feat`, `fix`, `chore`, `refactor`, `docs`, `style`, `test`, `perf`, `ci`, `build`, or `revert`
|
||||||
|
- `<domain>` is a kebab-case name for the main affected area, e.g. `readme`
|
||||||
|
- `<message>` is a description in plain English of the changes at a high level
|
||||||
|
|
||||||
|
For example: `docs(readme): add installation instructions`.
|
||||||
|
|
||||||
|
Commits should contain a long-form description when relevant, or the message is not enough to describe the full nature of the changes. All commits sholud be limited to 80 characters line length.
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)!
|
||||||
17
README.md
17
README.md
@@ -1,4 +1,4 @@
|
|||||||
<img src="/meta/phosphor-mark-tight-yellow.png" width="128" align="right" />
|
<img src="/meta/phosphor-mark-tight-black.png" width="96" align="right" />
|
||||||
|
|
||||||
# Phosphor Icons
|
# Phosphor Icons
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ Phosphor is available for [web](https://github.com/phosphor-icons/web), [React](
|
|||||||
- **Simple to use** – We use a similar approach as many other icon sets out there, providing icons as a webfont that uses Unicode's Private Use Area character codes to map normally non-rendering characters to icons. But you don't need to know that. All you need to do is add the script to the document `<head>`, and drop in icons with an `<i/>` tag and the appropriate class:
|
- **Simple to use** – We use a similar approach as many other icon sets out there, providing icons as a webfont that uses Unicode's Private Use Area character codes to map normally non-rendering characters to icons. But you don't need to know that. All you need to do is add the script to the document `<head>`, and drop in icons with an `<i/>` tag and the appropriate class:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="https://unpkg.com/@phosphor-icons/web"></script>
|
<script src="https://unpkg.com/@phosphor-icons/web"></script>
|
||||||
@@ -67,14 +67,14 @@ ReactDOM.render(<App />, document.getElementById("root"));
|
|||||||
```html
|
```html
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ph-horse />
|
<PhHorse />
|
||||||
<ph-heart :size="32" color="hotpink" weight="fill" />
|
<PhHeart :size="32" color="hotpink" weight="fill" />
|
||||||
<ph-cube />
|
<PhCube />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { PhHorse, PhHeart, PhCube } from "phosphor-vue";
|
import { PhHorse, PhHeart, PhCube } from "@phosphor-icons/vue";
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
components: {
|
components: {
|
||||||
@@ -108,8 +108,11 @@ ReactDOM.render(<App />, document.getElementById("root"));
|
|||||||
- [blade-phosphor-icons](https://github.com/codeat3/blade-phosphor-icons) ▲ Phosphor icons in your Laravel Blade views
|
- [blade-phosphor-icons](https://github.com/codeat3/blade-phosphor-icons) ▲ Phosphor icons in your Laravel Blade views
|
||||||
- [wireui/phosphoricons](https://github.com/wireui/phosphoricons) ▲ Phosphor icons for Laravel
|
- [wireui/phosphoricons](https://github.com/wireui/phosphoricons) ▲ Phosphor icons for Laravel
|
||||||
- [phosphor-css](https://github.com/lucagoslar/phosphor-css) ▲ CSS wrapper for Phosphor SVG icons
|
- [phosphor-css](https://github.com/lucagoslar/phosphor-css) ▲ CSS wrapper for Phosphor SVG icons
|
||||||
|
- [ruby-phosphor-icons](https://github.com/maful/ruby-phosphor-icons) ▲ Phosphor icons for Ruby and Rails applications
|
||||||
|
- [eleventy-plugin-phosphoricons](https://github.com/reatlat/eleventy-plugin-phosphoricons) ▲ An Eleventy plugin for add shortcode, allows Phosphor icons to be embedded as inline svg into templates
|
||||||
|
- [phosphor-leptos](https://github.com/SorenHolstHansen/phosphor-leptos) ▲ Phosphor icon component library for Leptos apps (rust)
|
||||||
|
|
||||||
If you've made a port of Phosphor and you want to see it here, just open a PR [here](https://github.com/phosphor-icons/phosphor-home)!
|
If you've made a port of Phosphor and you want to see it here, just open a PR [here](https://github.com/phosphor-icons/homepage)!
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
itemprop="image"
|
itemprop="image"
|
||||||
content="https://phosphoricons.com/phosphor-opengraph.png"
|
content="https://phosphoricons.com/phosphor-opengraph.png?v=2.0.2"
|
||||||
/>
|
/>
|
||||||
<script type="application/ld+json">
|
<script type="application/ld+json">
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
<meta property="og:url" content="https://phosphoricons.com" />
|
<meta property="og:url" content="https://phosphoricons.com" />
|
||||||
<meta
|
<meta
|
||||||
property="og:image"
|
property="og:image"
|
||||||
content="https://phosphoricons.com/phosphor-opengraph.png"
|
content="https://phosphoricons.com/phosphor-opengraph.png?v=2.0.2"
|
||||||
/>
|
/>
|
||||||
<meta property="og:image:type" content="image/png" />
|
<meta property="og:image:type" content="image/png" />
|
||||||
<meta property="og:image:alt" content="Phosphor Icons logo" />
|
<meta property="og:image:alt" content="Phosphor Icons logo" />
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
name="twitter:image"
|
name="twitter:image"
|
||||||
content="https://phosphoricons.com/phosphor-opengraph.png"
|
content="https://phosphoricons.com/phosphor-opengraph.png?v=2.0.2"
|
||||||
/>
|
/>
|
||||||
<meta name="twitter:site" content="@_phosphoricons" />
|
<meta name="twitter:site" content="@_phosphoricons" />
|
||||||
<meta name="twitter:creator" content="@friedtm" />
|
<meta name="twitter:creator" content="@friedtm" />
|
||||||
|
|||||||
BIN
meta/phosphor-mark-tight-acid.png
Normal file
BIN
meta/phosphor-mark-tight-acid.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
BIN
meta/phosphor-mark-tight-black.png
Normal file
BIN
meta/phosphor-mark-tight-black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
meta/phosphor-mark-tight-yellow-duo.png
Normal file
BIN
meta/phosphor-mark-tight-yellow-duo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
23
package.json
23
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "phosphor-home",
|
"name": "@phosphor-icons/homepage",
|
||||||
"version": "2.0.1",
|
"version": "2.0.6",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://phosphoricons.com",
|
"homepage": "https://phosphoricons.com",
|
||||||
"author": {
|
"author": {
|
||||||
@@ -27,19 +27,19 @@
|
|||||||
"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": "^2.0.2",
|
"@phosphor-icons/core": "^2.1.1",
|
||||||
"@phosphor-icons/react": "^2.0.4",
|
"@phosphor-icons/react": "^2.1.4",
|
||||||
|
"@recoiljs/refine": "^0.1.1",
|
||||||
"file-saver": "^2.0.2",
|
"file-saver": "^2.0.2",
|
||||||
"framer-motion": "^9.0.1",
|
"framer-motion": "^10.17.12",
|
||||||
"fuse.js": "^6.4.1",
|
"fuse.js": "^6.4.1",
|
||||||
"prop-types": "^15.8.1",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-dropdown-select": "^4.4.2",
|
"react-dropdown-select": "^4.4.2",
|
||||||
"react-ga4": "^2.0.0",
|
"react-ga4": "^2.1.0",
|
||||||
"react-hotkeys-hook": "^3.2.1",
|
"react-hotkeys-hook": "^4.4.3",
|
||||||
"react-use": "^17.4.0",
|
"recoil": "^0.7.7",
|
||||||
"recoil": "^0.7.6",
|
"recoil-sync": "^0.2.0",
|
||||||
"svg2png-converter": "^1.0.2",
|
"svg2png-converter": "^1.0.2",
|
||||||
"tinycolor2": "^1.4.2"
|
"tinycolor2": "^1.4.2"
|
||||||
},
|
},
|
||||||
@@ -50,8 +50,9 @@
|
|||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
"@types/tinycolor2": "^1.4.3",
|
"@types/tinycolor2": "^1.4.3",
|
||||||
"@vitejs/plugin-react": "^3.1.0",
|
"@vitejs/plugin-react": "^3.1.0",
|
||||||
|
"prettier": "^3.1.1",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
"vite": "^4.1.1",
|
"vite": "^4.5.2",
|
||||||
"vite-plugin-svgr": "^2.4.0"
|
"vite-plugin-svgr": "^2.4.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|||||||
1485
pnpm-lock.yaml
generated
Normal file
1485
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
public/LICENSE
Normal file
21
public/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020-2024 Phosphor Icons
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -142,26 +142,9 @@ button.main-button svg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.main-link {
|
a.main-link {
|
||||||
text-decoration: none;
|
|
||||||
position: relative;
|
|
||||||
color: var(--moss);
|
color: var(--moss);
|
||||||
}
|
}
|
||||||
|
|
||||||
a.main-link:after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0.15em;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
border-bottom: 1px solid var(--moss);
|
|
||||||
transition: 0.2s;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.main-link:hover:after {
|
|
||||||
width: 0%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
color: var(--foreground-secondary);
|
color: var(--foreground-secondary);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,40 +9,33 @@ import Footer from "@/components/Footer";
|
|||||||
import ErrorBoundary from "@/components/ErrorBoundary";
|
import ErrorBoundary from "@/components/ErrorBoundary";
|
||||||
import Notice from "@/components/Notice";
|
import Notice from "@/components/Notice";
|
||||||
// import Recipes from "@/components/Recipes";
|
// import Recipes from "@/components/Recipes";
|
||||||
import {
|
import { useCSSVariables } from "@/hooks";
|
||||||
useIconParameters,
|
|
||||||
usePersistSettings,
|
|
||||||
useCSSVariables,
|
|
||||||
} from "@/hooks";
|
|
||||||
import { isDarkThemeSelector } from "@/state";
|
import { isDarkThemeSelector } from "@/state";
|
||||||
|
|
||||||
const errorFallback = <Notice message="Search error" />;
|
const errorFallback = <Notice message="Search error" />;
|
||||||
const waitingFallback = <Notice type="none" message="" />;
|
const waitingFallback = <Notice type="none" message="" />;
|
||||||
|
|
||||||
const App: React.FC<any> = () => {
|
const App: React.FC<any> = () => {
|
||||||
useIconParameters();
|
|
||||||
usePersistSettings();
|
|
||||||
|
|
||||||
const isDark = useRecoilValue(isDarkThemeSelector);
|
const isDark = useRecoilValue(isDarkThemeSelector);
|
||||||
|
|
||||||
const properties = useMemo(
|
useCSSVariables(
|
||||||
() => ({
|
useMemo(
|
||||||
"--foreground": isDark ? "white" : "var(--moss)",
|
() => ({
|
||||||
"--foreground-card": isDark ? "white" : "var(--moss)",
|
"--foreground": isDark ? "white" : "var(--moss)",
|
||||||
"--foreground-secondary": isDark ? "var(--pewter)" : "var(--elephant)",
|
"--foreground-card": isDark ? "white" : "var(--moss)",
|
||||||
"--background": isDark ? "var(--slate)" : "var(--vellum)",
|
"--foreground-secondary": isDark ? "var(--pewter)" : "var(--elephant)",
|
||||||
"--background-card": isDark ? "var(--stone)" : "var(--vellum)",
|
"--background": isDark ? "var(--slate)" : "var(--vellum)",
|
||||||
"--background-layer": isDark ? "var(--scrim)" : "var(--translucent)",
|
"--background-card": isDark ? "var(--stone)" : "var(--vellum)",
|
||||||
"--border-card": isDark ? "var(--shadow)" : "var(--moss-shadow)",
|
"--background-layer": isDark ? "var(--scrim)" : "var(--translucent)",
|
||||||
"--border-secondary": isDark ? "var(--scrim)" : "var(--moss-shadow)",
|
"--border-card": isDark ? "var(--shadow)" : "var(--moss-shadow)",
|
||||||
"--hover-tabs": isDark ? "var(--slate-sheer)" : "var(--ghost-sheer)",
|
"--border-secondary": isDark ? "var(--scrim)" : "var(--moss-shadow)",
|
||||||
"--hover-buttons": isDark ? "var(--scrim)" : "var(--slate)",
|
"--hover-tabs": isDark ? "var(--slate-sheer)" : "var(--ghost-sheer)",
|
||||||
}),
|
"--hover-buttons": isDark ? "var(--scrim)" : "var(--slate)",
|
||||||
[isDark]
|
}),
|
||||||
|
[isDark]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
useCSSVariables(properties);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Header />
|
<Header />
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner {
|
.banner ::selection {
|
||||||
|
background-color: var(--moss-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner .main-button {
|
.banner .main-button {
|
||||||
@@ -67,6 +68,7 @@
|
|||||||
@media screen and (max-width: 719px) {
|
@media screen and (max-width: 719px) {
|
||||||
.banner-container {
|
.banner-container {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
gap: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner-content {
|
.banner-content {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type BannerProps = {
|
|||||||
const variants: Variants = {
|
const variants: Variants = {
|
||||||
initial: { y: -120 },
|
initial: { y: -120 },
|
||||||
animate: { y: 0 },
|
animate: { y: 0 },
|
||||||
exit: { y: -120 },
|
exit: { opacity: 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const BANNER_STATE_KEY = "banner_state";
|
const BANNER_STATE_KEY = "banner_state";
|
||||||
|
|||||||
@@ -6,16 +6,16 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
appearance: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker span {
|
.color-picker span {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
top: 50%;
|
inset: 0;
|
||||||
left: 50%;
|
|
||||||
-ms-transform: translate(-50%, -50%);
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@@ -46,4 +46,4 @@ input.color-input::-webkit-color-swatch {
|
|||||||
input.color-input:focus {
|
input.color-input:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { useRecoilState, useRecoilValue } from "recoil";
|
import { useRecoilState, useRecoilValue } from "recoil";
|
||||||
|
import { EyedropperSample } from "@phosphor-icons/react";
|
||||||
|
|
||||||
import { useThrottled } from "@/hooks";
|
import { useThrottled } from "@/hooks";
|
||||||
import { iconColorAtom, isDarkThemeSelector } from "@/state";
|
import { iconColorAtom, isDarkThemeSelector } from "@/state";
|
||||||
@@ -22,12 +23,21 @@ const ColorInput = (_: ColorInputProps) => {
|
|||||||
[setColor]
|
[setColor]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleSetInheritedColor = (e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setColor("currentColor");
|
||||||
|
};
|
||||||
|
|
||||||
const throttledColorChange = useThrottled(handleColorChange, 100, [
|
const throttledColorChange = useThrottled(handleColorChange, 100, [
|
||||||
handleColorChange,
|
handleColorChange,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="color-picker">
|
<div
|
||||||
|
className="color-picker"
|
||||||
|
title="Select a color, or right-click to use inherited color"
|
||||||
|
onContextMenu={handleSetInheritedColor}
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
className="color-input"
|
className="color-input"
|
||||||
aria-label="Icon Color"
|
aria-label="Icon Color"
|
||||||
@@ -36,7 +46,13 @@ const ColorInput = (_: ColorInputProps) => {
|
|||||||
onChange={throttledColorChange}
|
onChange={throttledColorChange}
|
||||||
value={color}
|
value={color}
|
||||||
/>
|
/>
|
||||||
<span style={{ color: isDark ? "black" : "white" }}>{color}</span>
|
<span style={{ color: isDark ? "black" : "white" }}>
|
||||||
|
{color === "currentColor" ? (
|
||||||
|
<EyedropperSample size={28} weight="fill" />
|
||||||
|
) : (
|
||||||
|
color
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, ErrorInfo, ReactNode } from "react";
|
import { Component, ErrorInfo, ReactNode } from "react";
|
||||||
|
import ReactGA from "react-ga4";
|
||||||
|
|
||||||
interface ErrorBoundaryProps {
|
interface ErrorBoundaryProps {
|
||||||
fallback?: JSX.Element | ReactNode;
|
fallback?: JSX.Element | ReactNode;
|
||||||
@@ -23,8 +24,16 @@ export default class ErrorBoundary extends Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch(error: any, info: ErrorInfo) {
|
componentDidCatch(error: any, info: ErrorInfo) {
|
||||||
void error;
|
console.error(error);
|
||||||
console.info(info);
|
ReactGA.event("exception", {
|
||||||
|
description: JSON.stringify({
|
||||||
|
error:
|
||||||
|
error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: error.toString?.() ?? "UNSERIALIZEABLE",
|
||||||
|
info,
|
||||||
|
}),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): JSX.Element | ReactNode {
|
render(): JSX.Element | ReactNode {
|
||||||
|
|||||||
@@ -87,14 +87,14 @@ const Footer = (_: FooterProps) => {
|
|||||||
Pablo Stanley
|
Pablo Stanley
|
||||||
</a>
|
</a>
|
||||||
,{" "}
|
,{" "}
|
||||||
<a className="main-link" href="https://remarkable.com/">
|
|
||||||
reMarkable
|
|
||||||
</a>
|
|
||||||
,{" "}
|
|
||||||
<a className="main-link" href="https://qatalog.com/">
|
<a className="main-link" href="https://qatalog.com/">
|
||||||
Qatalog
|
Qatalog
|
||||||
</a>
|
</a>
|
||||||
,{" "}
|
,{" "}
|
||||||
|
<a className="main-link" href="https://remarkable.com/">
|
||||||
|
reMarkable
|
||||||
|
</a>
|
||||||
|
,{" "}
|
||||||
<a className="main-link" href="https://www.spacedrive.com/">
|
<a className="main-link" href="https://www.spacedrive.com/">
|
||||||
Spacedrive
|
Spacedrive
|
||||||
</a>
|
</a>
|
||||||
@@ -112,7 +112,7 @@ const Footer = (_: FooterProps) => {
|
|||||||
Phosphor is free and open-source, licensed under{" "}
|
Phosphor is free and open-source, licensed under{" "}
|
||||||
<a
|
<a
|
||||||
className="main-link"
|
className="main-link"
|
||||||
href="https://raw.githubusercontent.com/phosphor-icons/phosphor-home/master/LICENSE"
|
href="https://raw.githubusercontent.com/phosphor-icons/homepage/master/LICENSE"
|
||||||
>
|
>
|
||||||
MIT
|
MIT
|
||||||
</a>
|
</a>
|
||||||
@@ -123,7 +123,7 @@ const Footer = (_: FooterProps) => {
|
|||||||
className="main-button"
|
className="main-button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
window.open(
|
window.open(
|
||||||
"https://paypal.me/minoraxis",
|
"https://www.buymeacoffee.com/phosphoricons",
|
||||||
"_blank",
|
"_blank",
|
||||||
"noopener noreferrer"
|
"noopener noreferrer"
|
||||||
)
|
)
|
||||||
@@ -149,14 +149,14 @@ const Footer = (_: FooterProps) => {
|
|||||||
<div className="fine-print">
|
<div className="fine-print">
|
||||||
<p>
|
<p>
|
||||||
Type set in{" "}
|
Type set in{" "}
|
||||||
<a className="main-link" href="https://manropefont.com/">
|
<a className="main-link" href="https://www.gent.media/manrope">
|
||||||
Manrope
|
Manrope
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
by Mikhail Sharanda and{" "}
|
by Mikhail Sharanda and{" "}
|
||||||
<a className="main-link" href="https://www.ibm.com/plex/">
|
<a className="main-link" href="https://www.ibm.com/plex/">
|
||||||
IBM Plex Mono
|
IBM Plex Mono
|
||||||
</a>.{" "}
|
</a>
|
||||||
Contact us at{" "}
|
. Contact us at{" "}
|
||||||
<a className="main-link" href="mailto:hello@phosphoricons.com">
|
<a className="main-link" href="mailto:hello@phosphoricons.com">
|
||||||
hello@phosphoricons.com
|
hello@phosphoricons.com
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
ArrowCircleUpRight,
|
ArrowCircleUpRight,
|
||||||
ArrowCircleDown,
|
ArrowCircleDown,
|
||||||
MegaphoneSimple,
|
MegaphoneSimple,
|
||||||
|
HandHeart,
|
||||||
} from "@phosphor-icons/react";
|
} from "@phosphor-icons/react";
|
||||||
|
|
||||||
import Banner from "@/components/Banner";
|
import Banner from "@/components/Banner";
|
||||||
@@ -39,16 +40,29 @@ const Header = (_: HeaderProps) => {
|
|||||||
return (
|
return (
|
||||||
<header>
|
<header>
|
||||||
<Banner.Container>
|
<Banner.Container>
|
||||||
<Banner id={"2.0.1"}>
|
<Banner id={"2.1.0"}>
|
||||||
<div className="message">
|
<div className="message">
|
||||||
<MegaphoneSimple size={32} mirrored />
|
<MegaphoneSimple size={32} mirrored />
|
||||||
<small>
|
<small>
|
||||||
Phosphor 2.0 is out, with some big updates and some small API
|
Phosphor v2.1 is out, adding 268 new icons and some general
|
||||||
changes. Check our{" "}
|
revisions. Check our{" "}
|
||||||
<a href="https://github.com/phosphor-icons/homepage#readme">
|
<a href="https://github.com/phosphor-icons/homepage/releases">
|
||||||
documentation
|
release notes
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
to see what's new!
|
to see what's changed!
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</Banner>
|
||||||
|
<Banner id={"buymeacoffee2"}>
|
||||||
|
<div className="message">
|
||||||
|
<HandHeart size={32} mirrored />
|
||||||
|
<small>
|
||||||
|
We are now processing donations via{" "}
|
||||||
|
<a href="https://www.buymeacoffee.com/phosphoricons">
|
||||||
|
Buy Me a Coffee
|
||||||
|
</a>
|
||||||
|
! Your one-time or recurring contribution does a lot to keep us
|
||||||
|
going. Please show us some support if you can!
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -87,11 +101,7 @@ const Header = (_: HeaderProps) => {
|
|||||||
<Synth className="synth inspectable xray" />
|
<Synth className="synth inspectable xray" />
|
||||||
|
|
||||||
<WatchSpec className="watch" />
|
<WatchSpec className="watch" />
|
||||||
<Watch className="watch inspectable xray">
|
<Watch className="watch inspectable xray" />
|
||||||
<foreignObject>
|
|
||||||
<span>FOOO</span>
|
|
||||||
</foreignObject>
|
|
||||||
</Watch>
|
|
||||||
|
|
||||||
<PaperClipsTwo id="paperclips" />
|
<PaperClipsTwo id="paperclips" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,10 +8,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.grid {
|
.grid {
|
||||||
display: flex;
|
display: grid;
|
||||||
flex-flow: row wrap;
|
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||||
justify-content: space-between;
|
max-width: 1152px;
|
||||||
max-width: 1120px;
|
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,8 +211,9 @@ figcaption > p {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-start; */
|
justify-content: flex-start; */
|
||||||
display: inline-grid;
|
display: inline-grid;
|
||||||
grid-template-columns: 66px 66px 92px;
|
grid-template-columns: 1fr 1fr;
|
||||||
gap: 6px;
|
max-height: 60px;
|
||||||
|
/* gap: 6px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-button {
|
.action-button {
|
||||||
@@ -255,9 +255,17 @@ figcaption > p {
|
|||||||
margin-inline: -10px;
|
margin-inline: -10px;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.detail-actions {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 536px) {
|
@media screen and (max-width: 536px) {
|
||||||
|
.grid {
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
.grid-item {
|
.grid-item {
|
||||||
width: 108px;
|
width: 108px;
|
||||||
height: unset;
|
height: unset;
|
||||||
|
|||||||
@@ -64,10 +64,15 @@ const IconGrid = (_: IconGridProps) => {
|
|||||||
<IconContext.Provider value={{ weight, size, color, mirrored: false }}>
|
<IconContext.Provider value={{ weight, size, color, mirrored: false }}>
|
||||||
<div className="grid-container">
|
<div className="grid-container">
|
||||||
<i id="beacon" className="beacon" />
|
<i id="beacon" className="beacon" />
|
||||||
<motion.div className="grid" initial="hidden" animate={controls}>
|
<motion.div
|
||||||
|
key={query}
|
||||||
|
className="grid"
|
||||||
|
initial="hidden"
|
||||||
|
animate={controls}
|
||||||
|
>
|
||||||
{filteredQueryResults.map((iconEntry, index) => (
|
{filteredQueryResults.map((iconEntry, index) => (
|
||||||
<IconGridItem
|
<IconGridItem
|
||||||
key={index}
|
key={iconEntry.name}
|
||||||
index={index}
|
index={index}
|
||||||
isDark={isDark}
|
isDark={isDark}
|
||||||
entry={iconEntry}
|
entry={iconEntry}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ interface IconGridItemProps extends HTMLAttributes<HTMLDivElement> {
|
|||||||
|
|
||||||
const transition = { duration: 0.2 };
|
const transition = { duration: 0.2 };
|
||||||
const originIndex = 0;
|
const originIndex = 0;
|
||||||
const delayPerPixel = 0.0004;
|
const delayPerPixel = 0.0003;
|
||||||
|
|
||||||
const itemVariants = {
|
const itemVariants = {
|
||||||
hidden: { opacity: 0 },
|
hidden: { opacity: 0 },
|
||||||
@@ -68,30 +68,28 @@ const IconGridItem = (props: IconGridItemProps) => {
|
|||||||
}, [originOffset]);
|
}, [originOffset]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<motion.div
|
||||||
<motion.div
|
className="grid-item"
|
||||||
className="grid-item"
|
key={name}
|
||||||
key={name}
|
ref={ref}
|
||||||
ref={ref}
|
tabIndex={0}
|
||||||
tabIndex={0}
|
style={{
|
||||||
style={{
|
...style,
|
||||||
...style,
|
backgroundColor: isOpen ? "var(--background-layer)" : undefined,
|
||||||
backgroundColor: isOpen ? "var(--background-layer)" : undefined,
|
}}
|
||||||
}}
|
custom={delayRef}
|
||||||
custom={delayRef}
|
transition={transition}
|
||||||
transition={transition}
|
variants={itemVariants}
|
||||||
variants={itemVariants}
|
onKeyPress={(e) => e.key === "Enter" && handleOpen()}
|
||||||
onKeyPress={(e) => e.key === "Enter" && handleOpen()}
|
onClick={handleOpen}
|
||||||
onClick={handleOpen}
|
>
|
||||||
>
|
<Icon />
|
||||||
<Icon />
|
<p>
|
||||||
<p>
|
<span className="name">{name}</span>
|
||||||
<span className="name">{name}</span>
|
{isNew && <span className="badge new">•</span>}
|
||||||
{isNew && <span className="badge new">•</span>}
|
{isUpdated && <span className="badge updated">•</span>}
|
||||||
{isUpdated && <span className="badge updated">•</span>}
|
</p>
|
||||||
</p>
|
</motion.div>
|
||||||
</motion.div>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
CaretDoubleLeft,
|
CaretDoubleLeft,
|
||||||
CaretDoubleRight,
|
CaretDoubleRight,
|
||||||
} from "@phosphor-icons/react";
|
} from "@phosphor-icons/react";
|
||||||
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
import ReactGA from "react-ga4";
|
import ReactGA from "react-ga4";
|
||||||
|
|
||||||
import Tabs, { Tab } from "@/components/Tabs";
|
import Tabs, { Tab } from "@/components/Tabs";
|
||||||
@@ -53,6 +54,7 @@ const RENDERED_SNIPPETS = [
|
|||||||
SnippetType.VUE,
|
SnippetType.VUE,
|
||||||
SnippetType.FLUTTER,
|
SnippetType.FLUTTER,
|
||||||
SnippetType.ELM,
|
SnippetType.ELM,
|
||||||
|
SnippetType.SWIFT,
|
||||||
];
|
];
|
||||||
|
|
||||||
enum CopyType {
|
enum CopyType {
|
||||||
@@ -61,6 +63,7 @@ enum CopyType {
|
|||||||
SVG_DATA,
|
SVG_DATA,
|
||||||
PNG,
|
PNG,
|
||||||
PNG_DATA,
|
PNG_DATA,
|
||||||
|
UNICODE,
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneWithSize(svg: SVGSVGElement, size: number): SVGSVGElement {
|
function cloneWithSize(svg: SVGSVGElement, size: number): SVGSVGElement {
|
||||||
@@ -75,12 +78,18 @@ const ActionButton = (
|
|||||||
active?: boolean;
|
active?: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
download?: boolean;
|
download?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
} & HTMLAttributes<HTMLButtonElement>
|
} & HTMLAttributes<HTMLButtonElement>
|
||||||
) => {
|
) => {
|
||||||
const { active, download, label, ...rest } = props;
|
const { active, download, label, ...rest } = props;
|
||||||
const Icon = download ? ArrowFatLinesDown : Copy;
|
const Icon = download ? ArrowFatLinesDown : Copy;
|
||||||
return (
|
return (
|
||||||
<button {...rest} className="action-button text" tabIndex={0}>
|
<button
|
||||||
|
{...rest}
|
||||||
|
className={`action-button text ${props.disabled ? "disabled" : ""}`}
|
||||||
|
aria-disabled={props.disabled}
|
||||||
|
tabIndex={0}
|
||||||
|
>
|
||||||
{active ? (
|
{active ? (
|
||||||
<CheckCircle size={20} color="var(--olive)" weight="fill" />
|
<CheckCircle size={20} color="var(--olive)" weight="fill" />
|
||||||
) : (
|
) : (
|
||||||
@@ -178,7 +187,7 @@ const Panel = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return [snippets, tabs];
|
return [snippets, tabs];
|
||||||
}, [entry, weight, size, copied, isDark]);
|
}, [entry, weight, size, color, copied, isDark]);
|
||||||
|
|
||||||
useHotkeys("esc", () => setSelectionEntry(null));
|
useHotkeys("esc", () => setSelectionEntry(null));
|
||||||
|
|
||||||
@@ -246,6 +255,14 @@ const Panel = () => {
|
|||||||
setCopied(CopyType.SVG_RAW);
|
setCopied(CopyType.SVG_RAW);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyUnicode = async () => {
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
const content = String.fromCharCode(entry.codepoint);
|
||||||
|
navigator.clipboard?.writeText(content);
|
||||||
|
setCopied(CopyType.UNICODE);
|
||||||
|
};
|
||||||
|
|
||||||
const handleDownloadSVG = (
|
const handleDownloadSVG = (
|
||||||
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
||||||
) => {
|
) => {
|
||||||
@@ -260,6 +277,18 @@ const Panel = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDownloadRawSVG = async () => {
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
const { name } = entry;
|
||||||
|
saveAs(
|
||||||
|
`https://raw.githubusercontent.com/phosphor-icons/core/main/raw/${weight}/${name}${
|
||||||
|
weight === "regular" ? "" : `-${weight}`
|
||||||
|
}.svg`,
|
||||||
|
`${entry?.name}${weight === "regular" ? "" : `-${weight}`}.svg`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleDownloadPNG = async (
|
const handleDownloadPNG = async (
|
||||||
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
||||||
) => {
|
) => {
|
||||||
@@ -324,7 +353,10 @@ const Panel = () => {
|
|||||||
<figcaption>
|
<figcaption>
|
||||||
<p>{entry.name}</p>
|
<p>{entry.name}</p>
|
||||||
<small className="versioning">
|
<small className="versioning">
|
||||||
available in v{entry.published_in.toFixed(1)}.0+
|
U+{entry.codepoint.toString(16).toUpperCase()}
|
||||||
|
</small>
|
||||||
|
<small className="versioning">
|
||||||
|
available in v{entry.published_in.toFixed(1)}+
|
||||||
</small>
|
</small>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
@@ -340,6 +372,13 @@ const Panel = () => {
|
|||||||
onClick={handleDownloadSVG}
|
onClick={handleDownloadSVG}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ActionButton
|
||||||
|
label="SVG Raw"
|
||||||
|
title="Download raw SVG including original strokes"
|
||||||
|
download
|
||||||
|
onClick={handleDownloadRawSVG}
|
||||||
|
/>
|
||||||
|
|
||||||
<ActionButton
|
<ActionButton
|
||||||
label="SVG"
|
label="SVG"
|
||||||
title="Copy SVG"
|
title="Copy SVG"
|
||||||
@@ -376,6 +415,14 @@ const Panel = () => {
|
|||||||
active={copied === CopyType.SVG_DATA}
|
active={copied === CopyType.SVG_DATA}
|
||||||
onClick={handleCopyDataSVG}
|
onClick={handleCopyDataSVG}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ActionButton
|
||||||
|
label="Unicode"
|
||||||
|
title="Copy Unicode character (v2.1.0 or newer)"
|
||||||
|
active={copied === CopyType.UNICODE}
|
||||||
|
disabled={weight === IconStyle.DUOTONE}
|
||||||
|
onClick={handleCopyUnicode}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -86,8 +86,11 @@ const Links = (_: LinksProps) => {
|
|||||||
<div>
|
<div>
|
||||||
<ArrowElbowDownRight size={24} />
|
<ArrowElbowDownRight size={24} />
|
||||||
<span>
|
<span>
|
||||||
<OutboundLink href="https://paypal.me/minoraxis" eventLabel="Donate">
|
<OutboundLink
|
||||||
Donate on PayPal
|
href="https://www.buymeacoffee.com/phosphoricons"
|
||||||
|
eventLabel="Donate"
|
||||||
|
>
|
||||||
|
Donate
|
||||||
</OutboundLink>
|
</OutboundLink>
|
||||||
{" / "}
|
{" / "}
|
||||||
<OutboundLink
|
<OutboundLink
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export type RecipeProps = {
|
|||||||
|
|
||||||
const Recipe = ({ url, Example }: RecipeProps) => {
|
const Recipe = ({ url, Example }: RecipeProps) => {
|
||||||
return (
|
return (
|
||||||
<a className="recipe card" href={url}>
|
<a className="recipe card" href={url} target="_blank">
|
||||||
{/* <h1>{title}</h1> */}
|
{/* <h1>{title}</h1> */}
|
||||||
<div className="recipe-linkout">
|
<div className="recipe-linkout">
|
||||||
<span>Open on StackBlitz</span>
|
<span>Open on StackBlitz</span>
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import { RecipeProps } from "../Recipe";
|
|||||||
|
|
||||||
const animation: RecipeProps = {
|
const animation: RecipeProps = {
|
||||||
title: "Hand Drawn",
|
title: "Hand Drawn",
|
||||||
url: "https://stackblitz.com/edit/react-ts-f7q7gs?file=App.tsx,style.css",
|
url: "https://stackblitz.com/edit/stackblitz-starters-4vqgkm?file=src%2FApp.tsx",
|
||||||
Example() {
|
Example() {
|
||||||
return (
|
return (
|
||||||
<div className="example">
|
<div className="example">
|
||||||
<CassetteTape
|
<CassetteTape
|
||||||
color="teal"
|
color="teal"
|
||||||
style={{ filter: "url(#displacementFilter)" }}
|
style={{ filter: "url(#displacementFilter)" }}
|
||||||
>
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<filter id="displacementFilter">
|
<filter id="displacementFilter">
|
||||||
<feTurbulence
|
<feTurbulence
|
||||||
@@ -30,18 +30,9 @@ const animation: RecipeProps = {
|
|||||||
</filter>
|
</filter>
|
||||||
</defs>
|
</defs>
|
||||||
</CassetteTape>
|
</CassetteTape>
|
||||||
<Cube
|
<Cube color="teal" style={{ filter: "url(#displacementFilter)" }} />
|
||||||
color="teal"
|
<ThumbsUp color="teal" style={{ filter: "url(#displacementFilter)" }} />
|
||||||
style={{ filter: "url(#displacementFilter)" }}
|
<Virus color="teal" style={{ filter: "url(#displacementFilter)" }} />
|
||||||
/>
|
|
||||||
<ThumbsUp
|
|
||||||
color="teal"
|
|
||||||
style={{ filter: "url(#displacementFilter)" }}
|
|
||||||
/>
|
|
||||||
<Virus
|
|
||||||
color="teal"
|
|
||||||
style={{ filter: "url(#displacementFilter)" }}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
ReactNode,
|
ReactNode,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { useDebounce } from "react-use";
|
|
||||||
import { useHotkeys } from "react-hotkeys-hook";
|
import { useHotkeys } from "react-hotkeys-hook";
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
@@ -16,6 +15,7 @@ import {
|
|||||||
} from "@phosphor-icons/react";
|
} from "@phosphor-icons/react";
|
||||||
import ReactGA from "react-ga4";
|
import ReactGA from "react-ga4";
|
||||||
|
|
||||||
|
import { useDebounce } from "@/hooks";
|
||||||
import { searchQueryAtom } from "@/state";
|
import { searchQueryAtom } from "@/state";
|
||||||
import "./SearchInput.css";
|
import "./SearchInput.css";
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ const SearchInput = (_: SearchInputProps) => {
|
|||||||
const inputRef =
|
const inputRef =
|
||||||
useRef<HTMLInputElement>() as MutableRefObject<HTMLInputElement>;
|
useRef<HTMLInputElement>() as MutableRefObject<HTMLInputElement>;
|
||||||
|
|
||||||
useHotkeys("ctrl+k,cmd+k", (e) => {
|
useHotkeys("ctrl+k,meta+k", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!e.repeat) {
|
if (!e.repeat) {
|
||||||
inputRef.current?.focus();
|
inputRef.current?.focus();
|
||||||
@@ -52,7 +52,7 @@ const SearchInput = (_: SearchInputProps) => {
|
|||||||
}, [query]);
|
}, [query]);
|
||||||
/* eslint-enable react-hooks/exhaustive-deps */
|
/* eslint-enable react-hooks/exhaustive-deps */
|
||||||
|
|
||||||
const [isReady] = useDebounce(
|
const [_isReady, _cancel] = useDebounce(
|
||||||
() => {
|
() => {
|
||||||
if (value !== query) {
|
if (value !== query) {
|
||||||
setQuery(value);
|
setQuery(value);
|
||||||
@@ -95,7 +95,7 @@ const SearchInput = (_: SearchInputProps) => {
|
|||||||
/>
|
/>
|
||||||
{!value && !isMobile && <Keys>{isApple ? <Command /> : "Ctrl + "}K</Keys>}
|
{!value && !isMobile && <Keys>{isApple ? <Command /> : "Ctrl + "}K</Keys>}
|
||||||
{value ? (
|
{value ? (
|
||||||
isReady() ? (
|
value === query ? (
|
||||||
<X className="clear-icon" size={18} onClick={handleCancelSearch} />
|
<X className="clear-icon" size={18} onClick={handleCancelSearch} />
|
||||||
) : (
|
) : (
|
||||||
<HourglassHigh className="wait-icon" weight="fill" size={18} />
|
<HourglassHigh className="wait-icon" weight="fill" size={18} />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ReactGA from "react-ga4";
|
import ReactGA from "react-ga4";
|
||||||
import { useRecoilState, useResetRecoilState } from "recoil";
|
import { useRecoilState, useResetRecoilState, useSetRecoilState } from "recoil";
|
||||||
import {
|
import {
|
||||||
ArrowCounterClockwise,
|
ArrowCounterClockwise,
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
@@ -21,21 +21,16 @@ import "./SettingsActions.css";
|
|||||||
|
|
||||||
const SettingsActions = () => {
|
const SettingsActions = () => {
|
||||||
const [weight, setWeight] = useRecoilState(iconWeightAtom);
|
const [weight, setWeight] = useRecoilState(iconWeightAtom);
|
||||||
const [size, setSize] = useRecoilState(iconSizeAtom);
|
const setSize = useSetRecoilState(iconSizeAtom);
|
||||||
const [color, setColor] = useRecoilState(iconColorAtom);
|
const setColor = useSetRecoilState(iconColorAtom);
|
||||||
const reset = useResetRecoilState(resetSettingsSelector);
|
const reset = useResetRecoilState(resetSettingsSelector);
|
||||||
|
|
||||||
const [copied, setCopied] = useTransientState<boolean>(false, 2000);
|
const [copied, setCopied] = useTransientState<boolean>(false, 2000);
|
||||||
const [booped, setBooped] = useState<boolean>(false);
|
const [booped, setBooped] = useState<boolean>(false);
|
||||||
|
|
||||||
const copyDeepLinkToClipboard = () => {
|
const copyDeepLinkToClipboard = () => {
|
||||||
const paramString = new URLSearchParams([
|
|
||||||
["weight", weight.toString()],
|
|
||||||
["size", size.toString()],
|
|
||||||
["color", color.replace("#", "")],
|
|
||||||
]).toString();
|
|
||||||
void navigator.clipboard
|
void navigator.clipboard
|
||||||
?.writeText(`${window.location.host}?${paramString}`)
|
?.writeText(`${window.location.origin}${window.location.search}`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ const Tabs = ({ tabs, initialIndex = 0, onTabChange }: TabsProps) => {
|
|||||||
activeIndex === 0
|
activeIndex === 0
|
||||||
? contentStyles.activeLeft
|
? contentStyles.activeLeft
|
||||||
: activeIndex === tabs.length - 1
|
: activeIndex === tabs.length - 1
|
||||||
? contentStyles.activeRight
|
? contentStyles.activeRight
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{tabs[activeIndex]?.content}
|
{tabs[activeIndex]?.content}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
export { default as useCSSVariables } from "./useCSSVariables";
|
export { default as useCSSVariables } from "./useCSSVariables";
|
||||||
export { default as useDebounce } from "./useDebounce";
|
export { default as useDebounce } from "./useDebounce";
|
||||||
export { default as useEvent } from "./useEvent";
|
export { default as useEvent } from "./useEvent";
|
||||||
export { default as useIconParameters } from "./useIconParameters";
|
|
||||||
export { default as useLocalStorage } from "./useLocalStorage";
|
export { default as useLocalStorage } from "./useLocalStorage";
|
||||||
export { default as useMediaQuery } from "./useMediaQuery";
|
export { default as useMediaQuery } from "./useMediaQuery";
|
||||||
export { default as usePersistSettings } from "./usePersistSettings";
|
export { default as usePersistSettings } from "./usePersistSettings";
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ export type UseEventTarget = HTMLElement | SVGElement | Document | Window;
|
|||||||
export type UseEventMap<E extends UseEventTarget> = E extends HTMLElement
|
export type UseEventMap<E extends UseEventTarget> = E extends HTMLElement
|
||||||
? HTMLElementEventMap
|
? HTMLElementEventMap
|
||||||
: E extends SVGElement
|
: E extends SVGElement
|
||||||
? SVGElementEventMap
|
? SVGElementEventMap
|
||||||
: E extends Document
|
: E extends Document
|
||||||
? DocumentEventMap
|
? DocumentEventMap
|
||||||
: WindowEventMap;
|
: WindowEventMap;
|
||||||
|
|
||||||
export type UseEventType<E extends UseEventTarget> = keyof UseEventMap<E>;
|
export type UseEventType<E extends UseEventTarget> = keyof UseEventMap<E>;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ export type UseEventType<E extends UseEventTarget> = keyof UseEventMap<E>;
|
|||||||
export default function useEvent<
|
export default function useEvent<
|
||||||
K extends UseEventType<T>,
|
K extends UseEventType<T>,
|
||||||
M extends UseEventMap<T>,
|
M extends UseEventMap<T>,
|
||||||
T extends UseEventTarget = Document
|
T extends UseEventTarget = Document,
|
||||||
>(
|
>(
|
||||||
type: K,
|
type: K,
|
||||||
listener: (this: T, ev: M[K]) => any,
|
listener: (this: T, ev: M[K]) => any,
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import { useEffect } from "react";
|
|
||||||
import { useSearchParam } from "react-use";
|
|
||||||
import { useSetRecoilState } from "recoil";
|
|
||||||
import TinyColor from "tinycolor2";
|
|
||||||
import { IconStyle } from "@phosphor-icons/core";
|
|
||||||
|
|
||||||
import { iconColorAtom, iconWeightAtom, iconSizeAtom } from "../state/atoms";
|
|
||||||
|
|
||||||
export default () => {
|
|
||||||
const weight = useSearchParam("weight")?.replace(/["']/g, "");
|
|
||||||
const size = useSearchParam("size")?.replace(/["']/g, "");
|
|
||||||
const color = useSearchParam("color")?.replace(/["']/g, "");
|
|
||||||
|
|
||||||
const setColor = useSetRecoilState(iconColorAtom);
|
|
||||||
const setWeight = useSetRecoilState(iconWeightAtom);
|
|
||||||
const setSize = useSetRecoilState(iconSizeAtom);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (weight) {
|
|
||||||
if (weight.toUpperCase() in IconStyle) setWeight(weight as IconStyle);
|
|
||||||
}
|
|
||||||
}, [weight, setWeight]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (size) {
|
|
||||||
const normalizedSize = parseInt(size);
|
|
||||||
if (typeof normalizedSize === "number" && isFinite(normalizedSize))
|
|
||||||
setSize(Math.min(Math.max(normalizedSize, 16), 96));
|
|
||||||
}
|
|
||||||
}, [size, setSize]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (color) {
|
|
||||||
const normalizedColor = TinyColor(color);
|
|
||||||
if (normalizedColor.isValid()) setColor(normalizedColor.toHexString());
|
|
||||||
}
|
|
||||||
}, [color, setColor]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!weight && !size && !color) {
|
|
||||||
const persistedState = JSON.parse(
|
|
||||||
window.localStorage.getItem("__phosphor_settings__") || "null"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!!persistedState) {
|
|
||||||
const { weight, size, color } = persistedState;
|
|
||||||
if (weight) {
|
|
||||||
if (weight.toUpperCase() in IconStyle) setWeight(weight as IconStyle);
|
|
||||||
}
|
|
||||||
if (size) {
|
|
||||||
const normalizedSize = parseInt(size);
|
|
||||||
if (typeof normalizedSize === "number" && isFinite(normalizedSize))
|
|
||||||
setSize(Math.min(Math.max(normalizedSize, 16), 96));
|
|
||||||
}
|
|
||||||
if (color) {
|
|
||||||
const normalizedColor = TinyColor(color);
|
|
||||||
if (normalizedColor.isValid())
|
|
||||||
setColor(normalizedColor.toHexString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
};
|
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
import { useRef, useEffect, useCallback } from "react";
|
import { useRef, useEffect, useCallback, DependencyList } from "react";
|
||||||
|
|
||||||
type Callback = (...args: any) => void;
|
type Callback<T extends Array<unknown>> = (...args: T) => void;
|
||||||
|
|
||||||
export default (
|
const useThrottled = <T extends Array<unknown>>(
|
||||||
callback: Callback,
|
callback: Callback<T>,
|
||||||
delay: number,
|
delay: number,
|
||||||
dependencies: any[] = []
|
dependencies: DependencyList = []
|
||||||
) => {
|
): ((...args: T) => void) => {
|
||||||
const throttleRef = useRef<Boolean>(false);
|
const throttleRef = useRef<Boolean>(false);
|
||||||
const callbackRef = useRef<Callback>(callback);
|
const callbackRef = useRef<Callback<T>>(callback);
|
||||||
|
|
||||||
// Update the callback to be used, if it ever changes
|
// Update the callback to be used, if it ever changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
callbackRef.current = callback;
|
callbackRef.current = callback;
|
||||||
}, [callback]);
|
}, [callback]);
|
||||||
|
|
||||||
return useCallback<Callback>(
|
return useCallback<Callback<T>>(
|
||||||
(...args) => {
|
(...args) => {
|
||||||
if (throttleRef.current) return;
|
if (throttleRef.current) return;
|
||||||
|
|
||||||
@@ -29,3 +29,5 @@ export default (
|
|||||||
[delay, ...dependencies]
|
[delay, ...dependencies]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default useThrottled;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { useCallback, useEffect, useRef } from "react";
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
|
|
||||||
export type UseTimeoutFnReturn = [() => boolean | null, () => void, () => void];
|
export type UseTimeoutFnReturn = [
|
||||||
|
isReady: () => boolean | null,
|
||||||
|
clear: () => void,
|
||||||
|
set: () => void,
|
||||||
|
];
|
||||||
|
|
||||||
export default function useTimeoutFn(
|
export default function useTimeoutFn(
|
||||||
fn: Function,
|
fn: Function,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useTimeoutFn } from "react-use";
|
import useTimeoutFn from "./useTimeoutFn";
|
||||||
|
|
||||||
export default <T>(
|
export default <T>(
|
||||||
baseState: T,
|
baseState: T,
|
||||||
ms: number = 1000
|
ms: number = 1000
|
||||||
): [T, (transientValue: T) => void] => {
|
): [value: T, set: (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);
|
||||||
|
|
||||||
|
|||||||
165
src/index.tsx
165
src/index.tsx
@@ -1,10 +1,13 @@
|
|||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { RecoilRoot } from "recoil";
|
import { RecoilRoot } from "recoil";
|
||||||
|
import { RecoilURLSyncJSON } from "recoil-sync";
|
||||||
import App from "./components/App";
|
import App from "./components/App";
|
||||||
import ReactGA from "react-ga4";
|
import ReactGA from "react-ga4";
|
||||||
|
import ErrorBoundary from "./components/ErrorBoundary";
|
||||||
|
import Notice from "./components/Notice";
|
||||||
|
|
||||||
const GA_MEASUREMENT_ID = 'G-1C1REQCLFB'
|
const GA_MEASUREMENT_ID = "G-1C1REQCLFB";
|
||||||
ReactGA.initialize(GA_MEASUREMENT_ID);
|
ReactGA.initialize(GA_MEASUREMENT_ID);
|
||||||
|
|
||||||
const container = document.getElementById("root");
|
const container = document.getElementById("root");
|
||||||
@@ -13,12 +16,28 @@ const root = createRoot(container!);
|
|||||||
root.render(
|
root.render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<RecoilRoot>
|
<RecoilRoot>
|
||||||
<App />
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<Notice
|
||||||
|
message={
|
||||||
|
<p>
|
||||||
|
An error occurred. Try going{" "}
|
||||||
|
<a href={window.location.origin}>home</a>.
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<RecoilURLSyncJSON location={{ part: "queryParams" }}>
|
||||||
|
<App />
|
||||||
|
</RecoilURLSyncJSON>
|
||||||
|
</ErrorBoundary>
|
||||||
</RecoilRoot>
|
</RecoilRoot>
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`
|
console.log(
|
||||||
|
`
|
||||||
|
|
||||||
%c sphorphosphor %co%cspho
|
%c sphorphosphor %co%cspho
|
||||||
%c s%cphorphosphor %co%csphorpho%cs
|
%c s%cphorphosphor %co%csphorpho%cs
|
||||||
@@ -45,26 +64,122 @@ console.log(`
|
|||||||
%cThanks for your interest in Phosphor <3
|
%cThanks for your interest in Phosphor <3
|
||||||
Hire me at https://tobiasfried.com
|
Hire me at https://tobiasfried.com
|
||||||
`,
|
`,
|
||||||
"color: #8861A8;", "color: #442B78;", "color: #5B399F;",
|
"color: #8861A8;",
|
||||||
"color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #442B78;",
|
||||||
"color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #5B399F;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #8861A8;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #CE93FE;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #442B78;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #925BFF;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #442B78;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #65461E;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #8861A8;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #8861A8;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #CE93FE;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #CE93FE;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #442B78;",
|
||||||
"color: #65461E;", "color: #F7AC49;", "color: #65461E;", "color: #442B78;", "color: #925BFF;", "color: #442B78;",
|
"color: #925BFF;",
|
||||||
"color: #65461E;", "color: #A17030;", "color: #65461E;", "color: #442B78;", "color: #5B399F;", "color: #442B78;",
|
"color: #442B78;",
|
||||||
"color: #0E481F;", "color: #0E481E;",
|
"color: #65461E;",
|
||||||
"color: #0E481F;", "color: #0EA147;", "color: #19873A;",
|
"color: #F7AC49;",
|
||||||
"color: #0E481F;", "color: #0EA147;", "color: #19873A;",
|
"color: #65461E;",
|
||||||
"color: #0E481F;", "color: #0EA147;", "color: #19873A;",
|
"color: #8861A8;",
|
||||||
"color: #0E481F;", "color: #0EA147;", "color: #19873A;",
|
"color: #CE93FE;",
|
||||||
"color: #0E481F;", "color: #0EA147;", "color: #19873A;",
|
"color: #442B78;",
|
||||||
"color: #0E481F;", "color: #0EA147;", "color: #19873A;",
|
"color: #925BFF;",
|
||||||
"color: #A17030;"
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #8861A8;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #CE93FE;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #F7AC49;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #925BFF;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #A17030;",
|
||||||
|
"color: #65461E;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #5B399F;",
|
||||||
|
"color: #442B78;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0E481E;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0EA147;",
|
||||||
|
"color: #19873A;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0EA147;",
|
||||||
|
"color: #19873A;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0EA147;",
|
||||||
|
"color: #19873A;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0EA147;",
|
||||||
|
"color: #19873A;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0EA147;",
|
||||||
|
"color: #19873A;",
|
||||||
|
"color: #0E481F;",
|
||||||
|
"color: #0EA147;",
|
||||||
|
"color: #19873A;",
|
||||||
|
"color: #A17030;"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ export enum SnippetType {
|
|||||||
HTML = "Web",
|
HTML = "Web",
|
||||||
FLUTTER = "Flutter",
|
FLUTTER = "Flutter",
|
||||||
ELM = "Elm",
|
ELM = "Elm",
|
||||||
|
SWIFT = "Swift",
|
||||||
}
|
}
|
||||||
|
|||||||
85
src/state/RecoilSyncLocalStorage.tsx
Normal file
85
src/state/RecoilSyncLocalStorage.tsx
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { useCallback, ReactNode } from "react";
|
||||||
|
import { DefaultValue } from "recoil";
|
||||||
|
import { ReadItem, WriteItems, ListenToItems, RecoilSync } from "recoil-sync";
|
||||||
|
import { STORAGE_KEY } from ".";
|
||||||
|
|
||||||
|
const DEFAULT_VALUE = new DefaultValue();
|
||||||
|
|
||||||
|
export default ({ children }: { children: ReactNode }) => {
|
||||||
|
const read: ReadItem = useCallback((itemKey) => {
|
||||||
|
if (typeof document === "undefined") return DEFAULT_VALUE; // SSR
|
||||||
|
|
||||||
|
const item = localStorage.getItem(itemKey);
|
||||||
|
|
||||||
|
let parsed: unknown;
|
||||||
|
|
||||||
|
try {
|
||||||
|
parsed = item === null ? DEFAULT_VALUE : parseJSON(item);
|
||||||
|
} catch {
|
||||||
|
parsed = DEFAULT_VALUE;
|
||||||
|
console.warn({ itemKey, item }, "parseJSON failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const write: WriteItems = useCallback(({ diff }) => {
|
||||||
|
if (typeof document === "undefined") return; // SSR
|
||||||
|
|
||||||
|
for (const [key, value] of diff) {
|
||||||
|
if (value instanceof DefaultValue) {
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
} else {
|
||||||
|
// reasons for setItem to fail: https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem#exceptions
|
||||||
|
try {
|
||||||
|
localStorage.setItem(key, JSON.stringify(value));
|
||||||
|
} catch (err) {
|
||||||
|
console.warn({ err, key, value }, "localStorage.setItem failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const listen: ListenToItems = useCallback(
|
||||||
|
({ updateItem, updateAllKnownItems }) => {
|
||||||
|
void updateAllKnownItems;
|
||||||
|
const onStorage = (event: StorageEvent) => {
|
||||||
|
// ignore clear() calls
|
||||||
|
if (event.storageArea === localStorage && event.key !== null) {
|
||||||
|
let parsed: unknown;
|
||||||
|
try {
|
||||||
|
parsed =
|
||||||
|
event.newValue === null
|
||||||
|
? DEFAULT_VALUE
|
||||||
|
: parseJSON(event.newValue);
|
||||||
|
} catch {
|
||||||
|
parsed = DEFAULT_VALUE;
|
||||||
|
console.warn({ event }, "parseJSON failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
updateItem(event.key, parsed);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("storage", onStorage);
|
||||||
|
|
||||||
|
return () => window.removeEventListener("storage", onStorage);
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RecoilSync
|
||||||
|
storeKey={STORAGE_KEY}
|
||||||
|
read={read}
|
||||||
|
write={write}
|
||||||
|
listen={listen}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</RecoilSync>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function parseJSON(value: string): unknown {
|
||||||
|
return value === "undefined" ? undefined : JSON.parse(value);
|
||||||
|
}
|
||||||
@@ -1,25 +1,91 @@
|
|||||||
import { atom } from "recoil";
|
import { atom } from "recoil";
|
||||||
|
import { syncEffect } from "recoil-sync";
|
||||||
|
import TinyColor from "tinycolor2";
|
||||||
|
import { custom, stringLiterals } from "@recoiljs/refine";
|
||||||
import { IconStyle } from "@phosphor-icons/core";
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
import { IconEntry } from "@/lib";
|
import { IconEntry } from "@/lib";
|
||||||
|
|
||||||
export const searchQueryAtom = atom<string>({
|
export const searchQueryAtom = atom<string>({
|
||||||
key: "searchQuery",
|
key: "searchQuery",
|
||||||
default: "",
|
default: "",
|
||||||
|
effects: [
|
||||||
|
syncEffect({
|
||||||
|
itemKey: "q",
|
||||||
|
refine: custom((q) => {
|
||||||
|
return (q as string).toString() ?? "";
|
||||||
|
}),
|
||||||
|
syncDefault: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const iconWeightAtom = atom<IconStyle>({
|
export const iconWeightAtom = atom<IconStyle>({
|
||||||
key: "iconWeight",
|
key: "iconWeight",
|
||||||
default: IconStyle.REGULAR,
|
default: IconStyle.REGULAR,
|
||||||
|
effects: [
|
||||||
|
syncEffect<IconStyle>({
|
||||||
|
itemKey: "weight",
|
||||||
|
refine: stringLiterals({
|
||||||
|
thin: IconStyle.THIN,
|
||||||
|
light: IconStyle.LIGHT,
|
||||||
|
regular: IconStyle.REGULAR,
|
||||||
|
bold: IconStyle.BOLD,
|
||||||
|
fill: IconStyle.FILL,
|
||||||
|
duotone: IconStyle.DUOTONE,
|
||||||
|
}),
|
||||||
|
write: (atom, w) => {
|
||||||
|
if (typeof w === "string") {
|
||||||
|
atom.write("weight", w);
|
||||||
|
} else {
|
||||||
|
atom.reset("weight");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
syncDefault: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const iconSizeAtom = atom<number>({
|
export const iconSizeAtom = atom<number>({
|
||||||
key: "iconSize",
|
key: "iconSize",
|
||||||
default: 32,
|
default: 32,
|
||||||
|
effects: [
|
||||||
|
syncEffect({
|
||||||
|
itemKey: "size",
|
||||||
|
refine: custom((s) => {
|
||||||
|
const size = Number.isFinite(Number(s)) ? Number(s) : 32;
|
||||||
|
return Math.min(Math.max(size, 16), 96);
|
||||||
|
}),
|
||||||
|
syncDefault: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const iconColorAtom = atom<string>({
|
export const iconColorAtom = atom<string>({
|
||||||
key: "iconColor",
|
key: "iconColor",
|
||||||
default: "#000000",
|
default: "#000000",
|
||||||
|
effects: [
|
||||||
|
syncEffect({
|
||||||
|
itemKey: "color",
|
||||||
|
refine: custom((c) => {
|
||||||
|
if (typeof c === "string") {
|
||||||
|
const normalizedColor = TinyColor(c);
|
||||||
|
if (normalizedColor.isValid()) {
|
||||||
|
return normalizedColor.toHexString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "#000000";
|
||||||
|
}),
|
||||||
|
write: (atom, c) => {
|
||||||
|
if (typeof c === "string") {
|
||||||
|
const color = c.replace("#", "");
|
||||||
|
atom.write("color", color);
|
||||||
|
} else {
|
||||||
|
atom.reset("color");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
syncDefault: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const iconPreviewOpenAtom = atom<string | false>({
|
export const iconPreviewOpenAtom = atom<string | false>({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { selector, selectorFamily } from "recoil";
|
import { selector, selectorFamily } from "recoil";
|
||||||
import TinyColor from "tinycolor2";
|
import TinyColor from "tinycolor2";
|
||||||
|
// @ts-ignore
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import { IconCategory } from "@phosphor-icons/core";
|
import { IconCategory } from "@phosphor-icons/core";
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ export const filteredQueryResultsSelector = selector<ReadonlyArray<IconEntry>>({
|
|||||||
if (!query) return icons;
|
if (!query) return icons;
|
||||||
|
|
||||||
return new Promise((resolve) =>
|
return new Promise((resolve) =>
|
||||||
|
// @ts-ignore
|
||||||
resolve(fuse.search(query).map((value) => value.item))
|
resolve(fuse.search(query).map((value) => value.item))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
import { IconStyle } from "@phosphor-icons/core";
|
import { IconStyle } from "@phosphor-icons/core";
|
||||||
|
import TinyColor from "tinycolor2";
|
||||||
|
|
||||||
import { SnippetType } from "@/lib";
|
import { SnippetType } from "@/lib";
|
||||||
|
|
||||||
|
function u8ToCGFloatStr(value: number): string {
|
||||||
|
return (value / 255).toLocaleString("en-US", {
|
||||||
|
minimumFractionDigits: 0,
|
||||||
|
maximumFractionDigits: 4,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function getCodeSnippets({
|
export function getCodeSnippets({
|
||||||
name,
|
name,
|
||||||
displayName,
|
displayName,
|
||||||
@@ -17,8 +25,9 @@ export function getCodeSnippets({
|
|||||||
}): Record<SnippetType, string> {
|
}): Record<SnippetType, string> {
|
||||||
const isDefaultWeight = weight === "regular";
|
const isDefaultWeight = weight === "regular";
|
||||||
const isDefaultColor = color === "#000000";
|
const isDefaultColor = color === "#000000";
|
||||||
const elmName = displayName.replace(/^\w/, (c) => c.toLowerCase());
|
const camelName = displayName.replace(/^\w/, (c) => c.toLowerCase());
|
||||||
const elmWeight = weight.replace(/^\w/, (c) => c.toUpperCase());
|
const pascalWeight = weight.replace(/^\w/, (c) => c.toUpperCase());
|
||||||
|
const { r, g, b } = TinyColor(color).toRgb();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[SnippetType.HTML]: `<i class="ph${
|
[SnippetType.HTML]: `<i class="ph${
|
||||||
@@ -40,12 +49,21 @@ export function getCodeSnippets({
|
|||||||
},\n size: ${size.toFixed(1)},\n${
|
},\n size: ${size.toFixed(1)},\n${
|
||||||
!isDefaultColor ? ` color: Color(0xff${color.replace("#", "")}),\n` : ""
|
!isDefaultColor ? ` color: Color(0xff${color.replace("#", "")}),\n` : ""
|
||||||
})`,
|
})`,
|
||||||
[SnippetType.ELM]: `Phosphor.${elmName}${
|
[SnippetType.ELM]: `Phosphor.${camelName}${
|
||||||
isDefaultWeight ? "" : " " + elmWeight
|
isDefaultWeight ? "" : " " + pascalWeight
|
||||||
}
|
}
|
||||||
|> withSize ${size}
|
|> withSize ${size}
|
||||||
|> withSizeUnit "px"
|
|> withSizeUnit "px"
|
||||||
|> toHtml []`,
|
|> toHtml []`,
|
||||||
|
[SnippetType.SWIFT]: `Ph.${camelName}.${weight}${
|
||||||
|
!isDefaultColor
|
||||||
|
? `\n .color(red: ${u8ToCGFloatStr(r)}, green: ${u8ToCGFloatStr(
|
||||||
|
g
|
||||||
|
)}, blue: ${u8ToCGFloatStr(b)})`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
|
.frame(width: ${size}, height: ${size})
|
||||||
|
`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user