Compare commits

..
109 Commits
Author SHA1 Message Date
ionitron 89cba595a7 8.1.1 2026-11-19 20:46:43 +00:00
Shane 02456263e0 Merge commit from fork 2026-11-19 12:31:02 -08:00
Shane a00f3134a5 chore(release): sync package version with published 8.1.0 release (#1521) 2026-11-19 12:30:04 -08:00
d1e2c48641 feat(icon): add font icon support to ion-icon (#1502)
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
Co-authored-by: ionitron <hi@ionicframework.com>
2026-07-28 16:36:24 -04:00
b2d0708a51 chore(): improve build, lint, and test structure (#1498)
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
Co-authored-by: ionitron <hi@ionicframework.com>
2026-07-28 14:18:21 -04:00
OS-jacobbell 2a8e43aff0 chore(workflows): refactor github workflows for new npm auth (#1486) 2026-03-09 12:03:24 -06:00
ionitron a9d1b7e23d 8.0.13 2025-07-08 22:02:57 +00:00
Christian Bromann 8f5ebc425c fix: publish missing svgs 2025-07-08 15:02:14 -07:00
ionitron 809a6d2a45 8.0.12 2025-07-08 21:44:18 +00:00
Christian Bromann 5d34943550 fix: add missing collection-copy script 2025-07-08 14:43:35 -07:00
ionitron f81cf0034b 8.0.11 2025-07-07 22:50:23 +00:00
Christian Bromann 76a68e4629 fix(ci): run test when pushing to main 2025-07-07 15:46:42 -07:00
Christian Bromann 53fb2905fd testing: add new jest runner 2025-07-07 15:43:57 -07:00
Christian Bromann a1a8ba85bb fix: update dependencies 2025-07-07 14:02:39 -07:00
Brandy SmithandBrandy Smith 72e8c23ecd fix(ionicons): add direct ion-icon component import path (#1464)
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
2025-07-07 14:02:08 -07:00
ionitron d584c93c21 8.0.10 2025-07-02 19:08:40 +00:00
Sean Perkins 0e51cf1595 fix: stencil projects can build ionicons (#1462) 2025-07-02 12:08:02 -07:00
ionitron a9556e4901 8.0.9 2025-06-02 16:15:52 +00:00
Masahiko Sakakibara 505a7caeaa fix(): export ionicons.json in package exports (#1456) 2025-06-02 09:15:12 -07:00
Kenrick Tandrian 161eb6ad3c fix(docs): change module links (#1454) 2025-05-14 14:05:39 -07:00
ionitron 5d393395d3 8.0.8 2025-05-06 18:22:55 +00:00
Christian Bromann ac1b23751d chore: cleanup CHANGELOG file 2025-05-06 11:22:15 -07:00
Christian Bromann d9a095dea4 fix: fix export file path for /icons 2025-05-06 11:21:24 -07:00
ionitron 3dab196131 8.0.7 2025-05-06 18:17:46 +00:00
Brandy SmithandBrandy Smith 7f73379a7c docs(changelog): correct links and add two recent releases (#1451)
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
2025-05-06 07:59:07 -07:00
ionitron abda804f39 8.0.6 2025-05-05 22:56:10 +00:00
Christian Bromann b9858daaab fix(ci): uncomment ci pipeline 2025-05-05 15:55:32 -07:00
ionitron 0807bbe045 8.0.5 2025-05-05 22:52:55 +00:00
Christian Bromann 0269306a15 fix(ci): remove auth step 2025-05-05 15:52:04 -07:00
Christian Bromann be3fcd7a70 fix(ci): fix auth command 2025-05-05 15:50:01 -07:00
Christian Bromann 4921d70e32 fix(ci): fix auth command 2025-05-05 15:48:06 -07:00
Christian Bromann bef34677cd fix(ci): fix propagating version 2025-05-05 15:44:13 -07:00
Christian Bromann 2e393282c9 fix(ci): fix git set up 2025-05-05 15:42:38 -07:00
Christian Bromann ecfff506b9 fix(ci): retrieve new version from package.json 2025-05-05 15:32:25 -07:00
Christian Bromann 87161a14a5 fix(ci): dry run it 2025-05-05 15:24:20 -07:00
Christian Bromann b1893f4ef6 fix(ci): test a different token 2025-05-05 15:22:11 -07:00
Christian Bromann fa5244e544 8.0.4 2025-05-05 15:18:31 -07:00
Christian Bromann d0e18dab3e fix(ci): tweak release pipeline 2025-05-05 15:18:26 -07:00
Christian Bromann e4d8d28253 8.0.3 2025-05-05 15:13:58 -07:00
Christian Bromann 77e5de20c8 fix(ci): set token before push 2025-05-05 15:13:45 -07:00
Christian Bromann 17ea00ef3c 8.0.2 2025-05-05 15:06:01 -07:00
Christian Bromann 04975203b7 8.0.1 2025-05-05 14:56:52 -07:00
Christian Bromann 2ad4148057 fix(ci): set proper token 2025-05-05 14:56:22 -07:00
Christian Bromann 5b23d0a963 fix(ci): set up git before calling npm version 2025-05-05 14:53:56 -07:00
Christian Bromann 987d118b0b ci: update pipelines 2025-05-05 14:52:10 -07:00
Christian Bromann a380c95899 docs: missing ; in readme 2025-05-05 12:20:36 -07:00
Christian Bromann fe60bd2490 docs: clarify usage of addIcons 2025-05-05 12:19:42 -07:00
Christian Bromann ba27560096 fix: exports 2025-05-05 12:15:51 -07:00
Christian Bromann dcca52d3b2 v8.0.0 2025-05-02 08:26:41 -07:00
e04eccc868 breaking: modernize project (#1447)
* chore: update project dependencies

* remove lerna

* update build

* plugin fixes

* Icons do not display when the svg is loaded from a file:// URL in Safari

fixes #1298

* Update path fill in warning-outline.svg exclamation mark

* set currentColor - fixes #1420

* add bell tag to notifications icon - fixes #1090

* add sliders and filters tags to option icon - fixes #1060

* add loveseat tag to bed icon - closes #503

* add contacts tag to people-circle
closes #779

* fix data.json

* update data.json

* set up prettier

* fix contributing link

* prettier after rebase

* add missing rimraf

* add more comments

* run prettier as part of the build

* set module resolution to bundle

* consolidate contributing guidelines and coc as part of the root directory

* fix link

* copy svg into www

* cut me some visual slack

* Update readme.md

Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>

* Update package.json

Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>

* Update CONTRIBUTING.md

Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>

* remove generating collections

* ensure all directories exist

* only define snapshot tolerance in config

* update dependencies

* Update src/components/icon/request.ts

Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>

* Update src/components/icon/request.ts

Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>

* Update src/components/icon/request.ts

Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>

* Update src/components/icon/request.ts

Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>

* prettier

* update release pipeline

* fix exports

* recommend to use esm.sh as cdn

---------

Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
2025-05-02 08:04:17 -07:00
Kerk en IT 5266d14dac Resolve #1242 (#1393) 2025-04-16 16:15:09 -07:00
jcesarmobile 4477c02512 chore(ci): update actions to v4 (#1415) 2024-11-19 11:39:07 +01:00
Liam DeBeasi d55d438ef0 chore: merge feature-7.4 2024-05-01 15:19:36 -04:00
Liam DeBeasi 70135edf3a chore: sync 2024-05-01 15:16:30 -04:00
Liam DeBeasi 2ac03a16d4 chore: sync with main 2024-05-01 15:15:44 -04:00
Liam DeBeasi 31c83d9d12 merge release-7.4.0
Release 7.4.0
2024-05-01 15:14:21 -04:00
ionitron 0c34dde9e8 chore(): update package lock files 2024-05-01 19:11:34 +00:00
ionitron f1794e755a v7.4.0 2024-05-01 19:10:54 +00:00
Christian Bromann 87f2094890 feat: export setAssetPath (#1372)
resolves #1302
2024-05-01 14:57:37 -04:00
Liam DeBeasi 0963fe20b7 feat: add X logo (#1371)
resolves #1249
2024-05-01 14:41:10 -04:00
Liam DeBeasi 19fbe0bde7 refactor(icon): remove addition style (#1359)
The `stroke-width: 32px` line never applies because of the following line where we apply the CSS Variable. All versions of browsers that Ionicons supports also support CSS Variables, so the `stroke-width: 32px` line isn't needed anymore.
2024-05-01 18:30:04 +00:00
Christian Bromann 06a995eebb docs: add a section on custom svg paths (#1368) 2024-05-01 14:09:49 -04:00
Liam DeBeasi 71938d06a2 test: use optimized assets (#1354) 2024-03-29 11:24:24 -04:00
Liam DeBeasi e81ddbdb4b merge release-7.3.1
Release 7.3.1
2024-03-27 09:40:09 -04:00
Liam DeBeasi 89356a9824 chore: clean up changelog 2024-03-27 09:35:43 -04:00
ionitron d3759f9ee1 chore(): update package lock files 2024-03-27 13:35:00 +00:00
ionitron 8b041ece8f v7.3.1 2024-03-27 13:34:21 +00:00
Liam DeBeasi 63e60ec44c fix: filled ellipsis circle icons renders correctly (#1353)
resolves #1320
2024-03-22 16:54:35 -04:00
Liam DeBeasi 4350c67e44 chore(ionitron): add auto response for community feedback (#1352) 2024-03-22 16:47:55 -04:00
Liam DeBeasi b4ade9d887 feat: update server icon (#1259)
resolves #407
2024-03-22 16:24:15 -04:00
b63d12b0e4 docs: update readme to use latest and switch unpkg to jsdelivr (#1084)
* docs: switch unpkg to jsdelivr

* docs: fix script tag

* Update readme.md

* Update package.json

---------

Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
Co-authored-by: mo7amd <mo7amd@users.noreply.github.com>
2024-03-22 10:23:35 -04:00
Liam DeBeasi d09ddb6404 docs(contributing): clarify icon contributions (#1351) 2024-03-22 09:20:55 -04:00
Liam DeBeasi 1c3f59def5 chore: use local version of lerna (#1349) 2024-03-20 13:18:08 -04:00
Liam DeBeasi fdd70c6607 merge release-7.3.0
Feature 7.3.0
2024-03-20 09:55:33 -04:00
Liam DeBeasi d38cbac770 merge release-7.3.0
Release 7.3.0
2024-03-20 09:48:15 -04:00
Liam DeBeasi 30f23ae9f5 chore(ci): pass env token 2024-03-20 09:41:51 -04:00
Liam DeBeasi 707325863d chore(): update package lock files 2024-03-20 09:40:19 -04:00
ionitron 5688365fb3 v7.3.0 2024-03-20 13:37:40 +00:00
Liam DeBeasi 9862cec6e8 chore: sync with main
chore: sync with main
2024-03-20 09:35:00 -04:00
Liam DeBeasi b18e5a9228 chore: sync with main 2024-03-20 09:26:21 -04:00
Liam DeBeasi c1450932cb merge release-7.2.3
Release 7.2.3
2024-03-20 09:26:09 -04:00
Liam DeBeasi 0a299f7118 chore(); update package lock files 2024-03-20 09:19:03 -04:00
Liam DeBeasi 51efbde09f chore: clean up changelog 2024-03-20 09:18:33 -04:00
Liam DeBeasi eea9396f11 chore(ci): pull branch correctly 2024-03-20 09:18:20 -04:00
ionitron 35e276a33d v7.2.3 2024-03-20 13:15:02 +00:00
Liam DeBeasiandchristophdubach 2586fb26b2 feat: update gitlab logo (#1261)
resolves #613

---------

Co-authored-by: christophdubach <christophdubach@users.noreply.github.com>
2024-03-13 19:50:06 -04:00
Liam DeBeasi c6ed6b629e feat: add updated yahoo icon (#1266) 2024-03-13 23:47:10 +00:00
Liam DeBeasi d5a55f8541 feat: add arrow box icons (#1265) 2024-03-13 23:44:14 +00:00
Liam DeBeasi 26aac36334 feat: add updated wifi logos (#1264)
resolves #323
2024-03-13 23:37:45 +00:00
Liam DeBeasi 50fe570566 feat: update ionic logo (#1263) 2024-03-13 23:14:53 +00:00
Liam DeBeasi fa5e7659fc feat: add appflow icon (#1262) 2024-03-13 19:12:29 -04:00
Liam DeBeasi 3b85413a05 feat: add trapeze icon (#1260) 2024-03-13 19:08:02 -04:00
Liam DeBeasi 302481846e feat: add binoculars icons (#1258) 2024-03-13 18:45:28 -04:00
Liam DeBeasi 8e22a3dcd1 chore: sync with main
chore: sync with main
2024-03-13 17:59:46 -04:00
MasonVXandNico Tasche 077168dac9 fix(icon): icon names with numbers are correctly converted to kebab case (#1339)
resolves #1338

---------

Co-authored-by: Nico Tasche <nico.tasche@siemens.com>
2024-03-13 17:55:43 -04:00
Liam DeBeasi e4debc5ecb chore: sync with main 2024-03-13 17:54:45 -04:00
Liam DeBeasi de8b11e892 chore(ci): package-lock is updated from separate job (#1308) 2024-01-02 12:44:33 -05:00
Liam DeBeasi 64bbbf997b chore: SVG optimization no longer breaks outline icons (#1313) 2023-12-18 20:26:32 +00:00
Liam DeBeasi c7f561ce41 test: refactor to use toHaveScreenshot (#1314) 2023-12-14 12:52:50 -08:00
Shawn Taylor 116d250255 chore(CODEOWNERS): remove codeowners (#1312) 2023-12-13 17:50:32 -05:00
Liam DeBeasi 49b727ca0d merge release-7.2.2
Release 7.2.2
2023-12-13 10:33:59 -05:00
Liam DeBeasi 811a814ef9 chore: clean up 2023-12-13 09:41:34 -05:00
ionitron 54d5a17c13 chore(): update package lock files 2023-12-13 14:40:09 +00:00
ionitron fccc260627 v7.2.2 2023-12-13 14:40:04 +00:00
Piotr Tomiak f946a3ee3a feat(doc): add Web Types (#1301) 2023-11-15 11:53:55 -05:00
Liam DeBeasi d582e6208e fix(icon): add better warning when loading icons (#1297) 2023-11-06 16:28:38 -05:00
Sean Perkins 625d54fdad merge release-7.2.1
v7.2.1
2023-10-10 13:37:32 -04:00
Liam DeBeasi 841fb96543 remove duplicate entry 2023-10-10 13:21:53 -04:00
ionitron 9dab13aef7 chore(): update package lock files 2023-10-10 17:10:51 +00:00
157 changed files with 8761 additions and 23522 deletions
-17
View File
@@ -1,17 +0,0 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.
# More details are here: https://help.github.com/articles/about-codeowners/
# The '*' pattern is global owners.
# Order is important. The last matching pattern has the most precedence.
# The folders are ordered as follows:
# In each subsection folders are ordered first by depth, then alphabetically.
# This should make it easy to add new rules without breaking existing ones.
# Global Owner
* @mapsandapps
-73
View File
@@ -1,73 +0,0 @@
# Contributing
Thanks for your interest in contributing to Ionicons! :tada:
## Contributing Etiquette
Please see our [Contributor Code of Conduct](./CODE_OF_CONDUCT.md) for information on our rules of conduct.
## Creating an Issue
* If you have a question about using Ionicons, please ask on the [Ionic Forum](http://forum.ionicframework.com/) or in the [Ionic Discord](https://ionic.link/discord).
* It is required that you clearly describe the steps necessary to reproduce the issue you are running into. Although we would love to help our users as much as possible, diagnosing issues without clear reproduction steps is extremely time-consuming and simply not sustainable.
* The issue list of this repository is exclusively for bug reports and feature requests. Non-conforming issues will be closed immediately.
* If you think you have found a bug, or have a new feature idea, please start by making sure it hasn't already been [reported](https://github.com/ionic-team/ionicons/issues?utf8=%E2%9C%93&q=is%3Aissue). You can search through existing issues to see if there is a similar one reported. Include closed issues as it may have been closed with a solution.
* Next, [create a new issue](https://github.com/ionic-team/ionicons/issues/new/choose) that thoroughly explains the problem.
## Creating a Pull Request
* We appreciate you taking the time to contribute! Before submitting a pull request, we ask that you please [create an issue](#creating-an-issue) that explains the bug or feature request and let us know that you plan on creating a pull request for it. If an issue already exists, please comment on that issue letting us know you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.
* Looking for an issue to fix? Make sure to look through our issues with the [help wanted](https://github.com/ionic-team/ionicons/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) label!
### Setup
1. [Download the installer](https://nodejs.org/) for the LTS version of Node.js. This is the best way to also [install npm](https://blog.npmjs.org/post/85484771375/how-to-install-npm#_=_).
2. Fork this repository.
3. Clone your fork.
4. Create a new branch from master for your change.
5. Run `npm install` from the root directory to install dependencies for this package.
6. Run `npm run build` to perform a first time build.
7. [Modify the Icon Component](#modifying-components) if desired.
8. Or, modify and [preview the site](#preview-site).
#### Modifying Components
1. Navigate to the `src/components/` directory and open the `icon` component to modify.
2. Make any changes to the icon component and then [preview the changes](#preview-component-changes).
#### Preview Component Changes
1. Run `npm start` from the root directory to start a local version of the icon test.
2. Modify the icon test as needed in the `index.html` file.
<!-- #### Building Changes
TODO -->
### Submit Pull Request
1. [Create a new pull request](https://github.com/ionic-team/ionicons/compare) with the `master` branch as the `base`. You may need to click on `compare across forks` to find your changes.
2. See the [Creating a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) GitHub help article for more information.
3. Please fill out the Pull Request template to the best of your ability and include any issues that are related.
## Updating Documentation
The documentation site for Ionicons is located in the [ionicons-site](https://github.com/ionic-team/ionicons-site) repository.
## License
By contributing your code to the ionic-team/ionicons GitHub Repository, you agree to license your contribution under the MIT license.
+2 -2
View File
@@ -1,7 +1,7 @@
name: 🐛 Bug Report
description: Report a bug in the ion-icon component. Incorrect icons should use the "Incorrect Icon" template instead.
labels: ["triage"]
title: "bug: "
labels: ['triage']
title: 'bug: '
body:
- type: textarea
attributes:
+3 -3
View File
@@ -1,7 +1,7 @@
name: 💡 Feature Request
description: Suggest a new feature for the ion-icon component. Icon requests should use the "Icon Request" template instead.
labels: ["triage"]
title: "feat: "
labels: ['triage']
title: 'feat: '
body:
- type: textarea
attributes:
@@ -20,4 +20,4 @@ body:
- type: textarea
attributes:
label: Additional Information
description: Add any other context or screenshots about the feature request here.
description: Add any other context or screenshots about the feature request here.
+3 -3
View File
@@ -1,7 +1,7 @@
name: 🚀 Icon Request
description: Request a new icon
labels: ["triage"]
title: "icon request: "
labels: ['triage']
title: 'icon request: '
body:
- type: textarea
attributes:
@@ -16,4 +16,4 @@ body:
- type: textarea
attributes:
label: Additional Information
description: Add any other context about the icon request here.
description: Add any other context about the icon request here.
+3 -3
View File
@@ -1,7 +1,7 @@
name: 😒 Incorrect Icon
description: Report an incorrect icon
labels: ["triage"]
title: "incorrect icon: "
labels: ['triage']
title: 'incorrect icon: '
body:
- type: textarea
attributes:
@@ -14,4 +14,4 @@ body:
label: Expected Behavior
description: A clear description of what the icon should look like. Please include any relevant screenshots.
validations:
required: true
required: true
+15 -3
View File
@@ -26,7 +26,7 @@ closeAndLock:
comment:
labels:
- label: "help wanted"
- label: 'help wanted'
message: >
This issue has been labeled as `help wanted`. This label is added to issues
that we believe would be good for contributors.
@@ -54,12 +54,24 @@ comment:
If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was
not enough for our team to reproduce the issue.
- label: 'community feedback wanted'
message: >
This issue has been labeled as `community feedback wanted`. This label is added to issues that we would like to hear from the community on before moving forward with any final decision on the feature request.
If the requested feature is something you would find useful for your applications, please react to the original post with 👍 (`+1`). If you would like to provide an additional use case for the feature, please post a comment.
The team will review this feedback and make a final decision. Any decision will be posted on this thread, but please note that we may ultimately decide not to pursue this feature.
Thank you!
dryRun: false
noReply:
days: 14
maxIssuesPerRun: 100
label: "needs: reply"
label: 'needs: reply'
responseLabel: triage
exemptProjects: true
exemptMilestones: true
@@ -77,7 +89,7 @@ noReply:
noReproduction:
days: 14
maxIssuesPerRun: 100
label: "ionitron: needs reproduction"
label: 'ionitron: needs reproduction'
responseLabel: triage
exemptProjects: true
exemptMilestones: true
@@ -3,14 +3,14 @@ description: 'Build Ionicons'
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Checkout the latest commit in this branch
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
- name: Cache Node Modules
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: node-modules
with:
@@ -31,4 +31,4 @@ runs:
with:
name: ionicons-src
output: IoniconsSrc.zip
paths: src
paths: src
@@ -10,10 +10,10 @@ inputs:
runs:
using: 'composite'
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
- name: Exract Archive
run: unzip -q -o ${{ inputs.path }}/${{ inputs.filename }}
shell: bash
shell: bash
@@ -10,14 +10,18 @@ inputs:
folder:
default: './'
description: 'A folder containing a package.json file.'
token:
description: 'The NPM authentication token required to publish.'
createRelease:
description: 'Create a release on GitHub.'
default: 'false'
ghToken:
description: 'The GitHub authentication token required to create a release.'
runs:
using: 'composite'
steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
- name: Install latest npm
run: npm install -g npm@latest
shell: bash
@@ -25,21 +29,35 @@ runs:
run: npm ci
shell: bash
working-directory: ${{ inputs.working-directory }}
- name: Set Git User
run: |
git config user.name ionitron
git config user.email hi@ionicframework.com
shell: bash
- name: Update Version
run: npm version ${{ inputs.version }} --git-tag-version false
id: update_version
run: |
npm version ${{ inputs.version }}
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
shell: bash
working-directory: ${{ inputs.working-directory }}
- name: Run Build
run: npm run build
shell: bash
working-directory: ${{ inputs.working-directory }}
- name: Prepare NPM Token
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
working-directory: ${{ inputs.working-directory }}
shell: bash
env:
NPM_TOKEN: ${{ inputs.token }}
- name: Publish to NPM
run: npm publish ${{ inputs.folder }} --tag ${{ inputs.tag }} --provenance
shell: bash
working-directory: ${{ inputs.working-directory }}
- name: Create Release
if: ${{ inputs.createRelease == 'true' }}
run: |
git remote set-url origin https://${GH_TOKEN}:x-oauth-basic@github.com/ionic-team/ionicons.git
git remote -v
git push origin main --tags
gh release create "v$VERSION" --title "v$VERSION" --generate-notes
shell: bash
env:
GH_TOKEN: ${{ inputs.ghToken }}
VERSION: ${{ env.VERSION }}
@@ -10,10 +10,10 @@ inputs:
runs:
using: 'composite'
steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
- name: Cache Node Modules
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: node-modules
with:
@@ -55,10 +55,8 @@ runs:
npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
git add src/\*.png --force
mkdir updated-screenshots
echo 'made dir'
rsync -R --progress $(git diff --name-only --cached) updated-screenshots
echo 'copied images'
if [ -d updated-screenshots ]; then
if [ "$(ls -A updated-screenshots)" ]; then
echo "hasUpdatedScreenshots=$(echo 'true')" >> $GITHUB_OUTPUT
cd updated-screenshots
ls
@@ -67,7 +65,7 @@ runs:
shell: bash
- name: Archive Updated Screenshots
if: inputs.update == 'true' && steps.test-and-update.outputs.hasUpdatedScreenshots == 'true'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: updated-screenshots-${{ inputs.shard }}-${{ inputs.totalShards }}
path: UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
@@ -83,4 +81,4 @@ runs:
with:
name: test-results-${{ inputs.shard }}-${{ inputs.totalShards }}
output: TestResults-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
paths: playwright-report
paths: playwright-report
@@ -3,10 +3,10 @@ description: 'Test Spec'
runs:
using: 'composite'
steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
- name: Cache Node Modules
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: node-modules
with:
@@ -7,8 +7,8 @@ on:
runs:
using: 'composite'
steps:
- uses: actions/setup-node@v3
- uses: actions/download-artifact@v3
- uses: actions/setup-node@v4
- uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Extract Archives
@@ -35,4 +35,4 @@ runs:
git add src/\*.png --force
git commit -m "chore(): add updated snapshots"
git push
shell: bash
shell: bash
@@ -13,7 +13,7 @@ runs:
- name: Create Archive
run: zip -q -r ${{ inputs.output }} ${{ inputs.paths }}
shell: bash
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.output }}
path: ${{ inputs.output }}
@@ -1,7 +1,7 @@
name: 'Ionicons Dev Build'
name: 'Dev Release'
on:
workflow_dispatch:
workflow_call:
jobs:
create-dev-hash:
@@ -9,7 +9,7 @@ jobs:
outputs:
dev-hash: ${{ steps.create-dev-hash.outputs.DEV_HASH }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --no-package-lock
shell: bash
@@ -20,13 +20,20 @@ jobs:
shell: bash
release-ionicons:
runs-on: ubuntu-latest
needs: [create-dev-hash]
uses: ./.github/workflows/release-ionicons.yml
with:
tag: dev
version: ${{ needs.create-dev-hash.outputs.dev-hash }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish to NPM
uses: ./.github/workflows/actions/publish-npm
with:
tag: dev
version: ${{ needs.create-dev-hash.outputs.dev-hash }}
working-directory: './'
createRelease: 'false'
get-build:
name: Get your dev build!
+28
View File
@@ -0,0 +1,28 @@
name: 'Production Release'
on:
workflow_call:
inputs:
version:
required: false
type: string
description: npm version (major, minor, or patch)
jobs:
release-ionicons:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.IONITRON_TOKEN }}
- name: Publish to NPM
uses: ./.github/workflows/actions/publish-npm
with:
tag: latest
version: ${{ inputs.version }}
working-directory: './'
createRelease: true
ghToken: ${{ secrets.IONITRON_TOKEN }}
-30
View File
@@ -1,30 +0,0 @@
name: 'Release Ionicons'
on:
workflow_call:
inputs:
version:
description: 'The type of version to release.'
type: string
required: true
tag:
description: 'The tag to publish to on NPM.'
type: string
required: true
secrets:
NPM_TOKEN:
required: true
jobs:
release-core:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/publish-npm
with:
tag: ${{ inputs.tag }}
version: ${{ inputs.version }}
working-directory: './'
token: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,37 @@
name: 'Release Orchestrator'
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release type'
required: true
type: choice
options:
- dev
- production
version:
description: 'Version for production releases'
required: false
type: choice
options:
- patch
- minor
- major
permissions:
id-token: write
contents: read
jobs:
run-dev:
if: ${{ inputs.release-type == 'dev' }}
uses: ./.github/workflows/dev-release.yml
secrets: inherit
run-production:
if: ${{ inputs.release-type == 'production' }}
uses: ./.github/workflows/production-release.yml
secrets: inherit
with:
version: ${{ inputs.version }}
-67
View File
@@ -1,67 +0,0 @@
name: 'Ionicons Production Release'
on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: Which version should be published?
options:
- patch
- minor
- major
tag:
required: true
type: choice
description: Which npm tag should this be published to?
options:
- latest
jobs:
release-ionicons:
uses: ./.github/workflows/release-ionicons.yml
with:
tag: ${{ inputs.tag }}
version: ${{ inputs.version }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
finalize-release:
needs: [release-ionicons]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.IONITRON_TOKEN }}
fetch-depth: 0
- name: Configure Identity
# Commits from github-actions do not
# trigger other GitHub Actions. As a result,
# we publish releases from Ionitron instead
# so actions run when merging the release branch
# back into main.
run: |
git config user.name ionitron
git config user.email hi@ionicframework.com
shell: bash
# This ensures the local version of Lerna is installed
# and that we do not use the global Lerna version
- name: Install root dependencies
run: npm ci
shell: bash
- name: Create GitHub Release
run: npx lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
# Lerna does not automatically bump versions
# of Ionicons dependencies that have changed,
# so we do that here.
- name: Bump Package Lock
run: |
npx lerna exec "npm install --package-lock-only --legacy-peer-deps"
git add .
git commit -m "chore(): update package lock files"
git push
shell: bash
+4 -4
View File
@@ -7,7 +7,7 @@ jobs:
build-core:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/build-core
test-e2e:
@@ -28,7 +28,7 @@ jobs:
needs: [build-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/test-e2e
with:
shard: ${{ matrix.shard }}
@@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test-e2e]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Normally, we could just push with the
# default GITHUB_TOKEN, but that will
# not cause the build workflow
@@ -49,4 +49,4 @@ jobs:
# to run when the screenshots are pushed.
with:
token: ${{ secrets.IONITRON_TOKEN }}
- uses: ./.github/workflows/actions/update-reference-screenshots
- uses: ./.github/workflows/actions/update-reference-screenshots
@@ -1,8 +1,10 @@
name: 'Ionicons Build'
name: 'Validation'
on:
pull_request:
branches: [ '**' ]
branches: ['**']
push:
branches: ['main']
# When pushing a new commit we should
# cancel the previous test run to not
@@ -15,7 +17,7 @@ jobs:
build-core:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Checkout the latest commit in this branch
ref: ${{ github.event.pull_request.head.sha }}
@@ -25,9 +27,9 @@ jobs:
needs: [build-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/test-spec
test-e2e:
strategy:
# This ensures that all screenshot shard
@@ -46,12 +48,12 @@ jobs:
needs: [build-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/test-e2e
with:
shard: ${{ matrix.shard }}
totalShards: ${{ matrix.totalShards }}
# Screenshots are required to pass
# in order for the branch to be merge
# eligible. However, the screenshot tests
@@ -68,4 +70,4 @@ jobs:
steps:
- name: Check build matrix status
if: ${{ needs.test-e2e.result != 'success' }}
run: exit 1
run: exit 1
+1
View File
@@ -24,3 +24,4 @@ www/
/playwright-report/
/playwright/.cache/
/src/**/*-snapshots
*.tgz
+1
View File
@@ -0,0 +1 @@
src/components.d.ts
+1 -149
View File
@@ -1,151 +1,3 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [7.2.1](https://github.com/ionic-team/ionicons/compare/v7.2.0...v7.2.1) (2023-10-10)
### Bug Fixes
* **icon:** font scales without host style ([#1289](https://github.com/ionic-team/ionicons/issues/1289)) ([875bfd8](https://github.com/ionic-team/ionicons/commit/875bfd8300144c62e55a5a76dc2cff8cf1f01bfe))
## [7.2.1](https://github.com/ionic-team/ionicons/compare/v7.2.0...v7.2.1) (2023-10-10)
### Bug Fixes
* **icon:** font scales without host style ([#1289](https://github.com/ionic-team/ionicons/issues/1289)) ([875bfd8](https://github.com/ionic-team/ionicons/commit/875bfd8300144c62e55a5a76dc2cff8cf1f01bfe))
# [7.2.0](https://github.com/ionic-team/ionicons/compare/v7.1.2...v7.2.0) (2023-10-10)
### Bug Fixes
* **icon:** mapping same icon does not warn ([#1279](https://github.com/ionic-team/ionicons/issues/1279)) ([8297018](https://github.com/ionic-team/ionicons/commit/8297018cb591f5e33a815ceb9e4e765271ecf5ad))
* **icon:** verify the icon loads in the lifecycle ([#1278](https://github.com/ionic-team/ionicons/issues/1278)) ([7f7f346](https://github.com/ionic-team/ionicons/commit/7f7f346af47f45531046e1d2f1a88f53acee77fa))
### Features
* allow passing in only icon SVG data to addIcons ([#1256](https://github.com/ionic-team/ionicons/issues/1256)) ([1e33313](https://github.com/ionic-team/ionicons/commit/1e3331347328c11a8b4c58c9200059bfd76b0e59))
* **icon:** support for dynamic type ([#1246](https://github.com/ionic-team/ionicons/issues/1246)) ([45c04dd](https://github.com/ionic-team/ionicons/commit/45c04dda6c905e535083b171cead374b1c993afa))
## [7.1.2](https://github.com/ionic-team/ionicons/compare/v7.1.1...v7.1.2) (2023-05-30)
### Bug Fixes
* **icon:** add :dir fallback ([#1223](https://github.com/ionic-team/ionicons/issues/1223)) ([06fa4a5](https://github.com/ionic-team/ionicons/commit/06fa4a528dd1906a5673ff6d80d22aef0f6e113b))
## [7.1.1](https://github.com/ionic-team/ionicons/compare/v7.1.0...v7.1.1) (2023-05-23)
### Bug Fixes
* **icon:** respond to changes of document dir ([#1210](https://github.com/ionic-team/ionicons/issues/1210)) ([e70bf21](https://github.com/ionic-team/ionicons/commit/e70bf214b82cd2187ea9394803283570d28ab28c))
# [7.1.0](https://github.com/ionic-team/ionicons/compare/v7.0.0...v7.1.0) (2023-03-23)
### Features
* chevron-expand and chevron-collapse icons ([#1198](https://github.com/ionic-team/ionicons/issues/1198)) ([cdb0d80](https://github.com/ionic-team/ionicons/commit/cdb0d80cde1dc5dd90fb2a1c3b4fa31d68294821))
# [7.0.0](https://github.com/ionic-team/ionicons/compare/v6.1.3...v7.0.0) (2023-03-07)
**Migration Note:** Developers should ensure that their `<ion-icon>` usages have either `aria-label` or `aria-hidden` to avoid accessibility issues. See https://ionic.io/ionicons/usage for more information.
### Bug Fixes
* **icon:** remove auto-generated aria-label ([#1170](https://github.com/ionic-team/ionicons/issues/1170)) ([98975ec](https://github.com/ionic-team/ionicons/commit/98975ec0f54b825c33f528683834a5e38298d598))
## [6.1.3](https://github.com/ionic-team/ionicons/compare/v6.1.2...v6.1.3) (2023-02-09)
### Bug Fixes
* DomParser usage in SSR ([#1180](https://github.com/ionic-team/ionicons/issues/1180)) ([8c412f6](https://github.com/ionic-team/ionicons/commit/8c412f67486d6cc9725de63f0c15b6c6cd8d47ce)), closes [#1179](https://github.com/ionic-team/ionicons/issues/1179)
## [6.1.2](https://github.com/ionic-team/ionicons/compare/v6.1.1...v6.1.2) (2023-02-08)
### Bug Fixes
* **icon:** load base64 data urls ([#1172](https://github.com/ionic-team/ionicons/issues/1172)) ([72f0936](https://github.com/ionic-team/ionicons/commit/72f09369de76b00697437f54d919782307843a87))
* **icon:** md and ios properties are reactive ([#1174](https://github.com/ionic-team/ionicons/issues/1174)) ([65bcbb4](https://github.com/ionic-team/ionicons/commit/65bcbb477734e33901a6f0c650d3f1f2c3084fca)), closes [#802](https://github.com/ionic-team/ionicons/issues/802)
## [6.1.1](https://github.com/ionic-team/ionicons/compare/v6.1.0...v6.1.1) (2023-01-18)
### Bug Fixes
* **icon:** remove <title> during build step ([#1169](https://github.com/ionic-team/ionicons/issues/1169)) ([93b4fa4](https://github.com/ionic-team/ionicons/commit/93b4fa449b0a072b24ef920fe73e1cb04d6f9b43)), closes [#1168](https://github.com/ionic-team/ionicons/issues/1168)
## [6.1.1](https://github.com/ionic-team/ionicons/compare/v6.1.0...v6.1.1) (2023-01-18)
### Bug Fixes
* **icon:** remove <title> during build step ([#1169](https://github.com/ionic-team/ionicons/issues/1169)) ([93b4fa4](https://github.com/ionic-team/ionicons/commit/93b4fa449b0a072b24ef920fe73e1cb04d6f9b43)), closes [#1168](https://github.com/ionic-team/ionicons/issues/1168)
# [6.1.0](https://github.com/ionic-team/ionicons/compare/v6.0.4...v6.1.0) (2023-01-17)
### Bug Fixes
* **icon:** remove default <title> ([#1166](https://github.com/ionic-team/ionicons/issues/1166)) ([e0efa5f](https://github.com/ionic-team/ionicons/commit/e0efa5f28d61adcaf2e1fa121f7e2f10cfad6d65)), closes [#838](https://github.com/ionic-team/ionicons/issues/838) [#1049](https://github.com/ionic-team/ionicons/issues/1049) [#1082](https://github.com/ionic-team/ionicons/issues/1082)
# [6.1.0](https://github.com/ionic-team/ionicons/compare/v6.0.4...v6.1.0) (2023-01-17)
### Bug Fixes
* **icon:** remove default <title> ([#1166](https://github.com/ionic-team/ionicons/issues/1166)) ([e0efa5f](https://github.com/ionic-team/ionicons/commit/e0efa5f28d61adcaf2e1fa121f7e2f10cfad6d65)), closes [#838](https://github.com/ionic-team/ionicons/issues/838) [#1049](https://github.com/ionic-team/ionicons/issues/1049) [#1082](https://github.com/ionic-team/ionicons/issues/1082)
Please see https://github.com/ionic-team/ionicons/releases
+196
View File
@@ -0,0 +1,196 @@
# Contributing to Ionicons
Thank you for your interest in contributing to Ionicons! :tada:
This document outlines the guidelines and processes for contributing to this project.
## Table of Contents
- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [Environment Setup](#environment-setup)
- [Development Workflow](#development-workflow)
* [Branch Strategy](#branch-strategy)
* [Component Modifications](#component-modifications)
* [Testing](#testing)
* [Code Style](#code-style)
* [Building](#building)
- [Submitting Issues](#submitting-issues)
- [Submitting Pull Requests](#submitting-pull-requests)
## Code of Conduct
Please read our [Contributor Code of Conduct](./CODE_OF_CONDUCT.md) for information on our rules of conduct. By contributing to Ionicons, you agree to abide by its terms.
## Getting Started
### Prerequisites
- [Node.js](https://nodejs.org/) (LTS version recommended)
- [npm](https://www.npmjs.com/) (comes with Node.js)
- Git
### Environment Setup
1. We recommend using [nvm](https://github.com/nvm-sh/nvm) (Node Version Manager) to manage Node.js versions:
- For macOS/Linux: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash`
- For Windows: Use [nvm-windows](https://github.com/coreybutler/nvm-windows)
- Install and use the LTS version: `nvm install --lts && nvm use --lts`
Alternatively, you can [download the installer](https://nodejs.org/) for the LTS version of Node.js directly.
2. Fork the repository on GitHub
3. Clone your fork locally:
```bash
git clone https://github.com/YOUR-USERNAME/ionicons.git
cd ionicons
```
4. Add the original repository as an upstream remote:
```bash
git remote add upstream https://github.com/ionic-team/ionicons.git
```
5. Create a new branch from `main` for your change:
```bash
git checkout -b your-feature-branch
```
6. Install dependencies:
```bash
npm install
```
7. Run the initial build:
```bash
npm run build
```
8. If desired, [modify the Icon Component](#component-modifications)
9. Or, modify and preview the site
## Development Workflow
### Branch Strategy
- Always create a new branch from `main` for your changes:
```bash
git checkout main
git pull upstream main
git checkout -b your-feature-branch
```
### Component Modifications
If you're modifying the `ion-icon` component:
1. Navigate to `src/components/` directory and open the `icon` component to modify
2. Make your changes to the component code
3. Test your changes locally with `npm start`
4. Run the full test suite: `npm run test.spec` for unit tests and `npm run test.e2e` for E2E tests
5. All PRs that change component behavior must include tests covering the changes
### Testing
Tests are crucial for maintaining confidence in changes. All PRs that modify component behavior must include tests covering those changes.
#### Local Development & Previewing
To preview component changes during development:
```bash
npm start
```
This starts the dev server with live-reloading. The test landing page displays all available test pages.
Test pages are organized in `src/components/icon/test/` with individual folders for each test scenario.
#### Unit Tests
Run Jest tests for component logic:
```bash
npm run test.spec
```
#### E2E Tests
Run Playwright tests to generate visual regression snapshots and verify component behavior:
```bash
npm run test.e2e
```
View the HTML report after tests complete:
```bash
npx playwright show-report
```
> [!IMPORTANT]
> All E2E test navigation URLs must include a trailing slash (e.g., `/icon/test/basic/` not `/icon/test/basic`). The trailing slash ensures proper directory routing, correct timing for script initialization, and consistent page loading across browsers.
##### Updating Snapshots
To update visual regression snapshots with new baselines:
```bash
npm run test.e2e -- --update-snapshots
```
Or for a specific test:
```bash
npm run test.e2e -- src/components/icon/test/basic/icon.e2e.ts --update-snapshots
```
> [!NOTE]
> Updating snapshots locally updates your gitignored screenshot files for local testing. To update the official repository snapshots, run the "Update Reference Screenshots" GitHub action with your development branch selected.
### Code Style
- This project uses Prettier for code formatting
- Run `npm run prettier` to format your code before submitting
### Building
- Run `npm run build` to build the complete package
- Run `npm run build.files` to rebuild only the SVG icon files
## Submitting Issues
Please submit issues for:
- Bug reports
- Feature requests
- General questions about the project
When creating issues:
1. If you have a question about using Ionicons, please ask on the [Ionic Forum](http://forum.ionicframework.com/) or in the [Ionic Discord](https://ionic.link/discord).
2. It is required that you clearly describe the steps necessary to reproduce the issue you are running into. Although we would love to help our users as much as possible, diagnosing issues without clear reproduction steps is extremely time-consuming and simply not sustainable.
3. The issue list of this repository is exclusively for bug reports and feature requests. Non-conforming issues will be closed immediately.
4. Check if a similar issue already exists by searching through [existing issues](https://github.com/ionic-team/ionicons/issues?utf8=%E2%9C%93&q=is%3Aissue). You can search through existing issues to see if there is a similar one reported. Include closed issues as it may have been closed with a solution.
5. Use the provided issue templates and clearly describe:
- Expected behavior
- Actual behavior
- Steps to reproduce (for bugs)
- Browser/device information when relevant
6. [Create a new issue](https://github.com/ionic-team/ionicons/issues/new/choose) that thoroughly explains the problem.
## Submitting Pull Requests
1. Before submitting a Pull Request (PR), please:
- Create an issue first to discuss the proposed changes
- Comment on an existing issue mentioning you'd like to work on it
- Look for issues labeled with [`help wanted`](https://github.com/ionic-team/ionicons/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) if you're new to the project
2. Creating the PR:
- Update your fork to the latest upstream main
- Make your changes in a new git branch
- Follow the code style of the project
- Include relevant tests
- Make sure all tests pass: `npm test`
- Update documentation if needed
- [Create a new pull request](https://github.com/ionic-team/ionicons/compare) with the `main` branch as the base.
+20
View File
@@ -0,0 +1,20 @@
import path from 'path';
import url from 'url';
import { createJestStencilPreset } from 'jest-stencil-runner';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
export default createJestStencilPreset({
rootDir: __dirname,
// Add any additional Jest configuration here
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
],
testMatch: [
'**/__tests__/**/*.(ts|tsx|js)',
'**/*.(test|spec).(ts|tsx|js)'
]
});
+2
View File
@@ -0,0 +1,2 @@
const Stencil = require('@stencil/core');
Stencil.Build.isBrowser = true;
-6
View File
@@ -1,6 +0,0 @@
{
"packages": [
"./"
],
"version": "7.2.1"
}
+5425 -22060
View File
File diff suppressed because it is too large Load Diff
+65 -24
View File
@@ -1,6 +1,6 @@
{
"name": "ionicons",
"version": "7.2.1",
"version": "8.1.1",
"description": "Premium icons for Ionic.",
"files": [
"components/",
@@ -10,36 +10,76 @@
"main": "./dist/index.cjs.js",
"module": "./dist/index.js",
"types": "dist/types/index.d.ts",
"unpkg": "dist/ionicons.js",
"unpkg": "dist/ionicons/ionicons.esm.js",
"jsdelivr": "dist/ionicons/ionicons.esm.js",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs.js"
},
"./loader": {
"types": "./dist/loader/index.d.ts",
"import": "./dist/loader/index.js",
"require": "./dist/loader/index.cjs.js"
},
"./components": {
"types": "./components/index.d.ts",
"import": "./components/index.js"
},
"./components/ion-icon.js": {
"types": "./components/ion-icon.d.ts",
"import": "./components/ion-icon.js"
},
"./icons": {
"types": "./icons/index.d.ts",
"import": "./icons/index.mjs",
"require": "./icons/index.js"
},
"./dist/ionicons.json": {
"default": "./dist/ionicons.json"
}
},
"scripts": {
"build": "tsc -p scripts/tsconfig.json && npm run build.files && npm run build.component && npm run collection.copy",
"build.files": "node scripts/build.js",
"build": "run-s clean build.*",
"build.files": "tsx scripts/build.ts",
"build.component": "stencil build",
"collection.copy": "node scripts/collection-copy.js",
"start": "stencil build --dev --watch --serve",
"test": "npm run test.spec",
"test.spec": "stencil test --spec"
"build.collection": "tsx scripts/collection-copy.ts",
"clean": "rimraf dist components icons www",
"lint": "npm run prettier -- --write",
"prettier": "prettier \"./src/**/*.{html,ts,tsx,js,jsx,scss}\"",
"prettier.dry-run": "npm run prettier -- --list-different",
"start": "run-s build.files && stencil build --dev --watch --serve",
"test": "run-s test.spec test.e2e",
"test.spec": "jest",
"test.e2e": "playwright test",
"test.e2e.install": "playwright install && playwright install-deps"
},
"dependencies": {
"@stencil/core": "^4.0.3"
"@stencil/core": "^4.43.5"
},
"devDependencies": {
"@playwright/test": "^1.33.0",
"@types/fs-extra": "^11.0.1",
"@types/jest": "^27.0.3",
"@types/node": "^20.2.1",
"@types/svgo": "^1.3.3",
"fs-extra": "^11.1.1",
"jest": "^27.0.3",
"jest-cli": "^27.0.3",
"lerna": "^6.6.2",
"puppeteer": "^20.2.1",
"semver": "^7.5.1",
"serve": "^14.2.0",
"svgo": "1.3.2",
"typescript": "^5.0.4"
"@axe-core/playwright": "^4.12.1",
"@playwright/test": "^1.61.1",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^30.0.0",
"@types/node": "^22.15.3",
"@types/svgo": "^3.0.0",
"fs-extra": "^11.3.0",
"jest": "^30.0.4",
"jest-cli": "^30.0.4",
"jest-stencil-runner": "^0.0.20",
"npm-run-all2": "^8.0.4",
"prettier": "^3.6.2",
"puppeteer": "^24.12.0",
"rimraf": "^6.0.1",
"semver": "^7.7.2",
"serve": "^14.2.4",
"svgo": "4.0.0",
"tsx": "^4.20.3",
"typescript": "^5.8.3"
},
"keywords": [
"icon pack",
@@ -74,5 +114,6 @@
"license": "MIT",
"sideEffects": [
"icons/imports/"
]
],
"web-types": "dist/ionic.web-types.json"
}
+17 -12
View File
@@ -1,7 +1,7 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices, expect } from '@playwright/test';
const projects = [
const projects: PlaywrightTestConfig['projects'] = [
{
/**
* This is really just desktop Firefox
@@ -19,10 +19,6 @@ const projects = [
viewport: {
width: 393,
height: 727
},
screen: {
width: 393,
height: 851
}
},
},
@@ -53,12 +49,21 @@ const config: PlaywrightTestConfig = {
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
toMatchSnapshot: {
/**
* Increases the maximum allowed pixel difference to account
* for slight browser rendering inconsistencies.
*/
maxDiffPixelRatio: 0.02
/**
* Configure screenshot comparison settings
* to be more tolerant of minor visual differences
*/
toHaveScreenshot: {
// Increase the threshold to allow for small font rendering differences
// This sets the maximum allowed ratio of pixels that can be different
maxDiffPixelRatio: 0.02, // Allow up to 2% of pixels to be different
// Alternatively, you can use absolute pixel count
// maxDiffPixels: 100, // Allow up to 100 pixels to be different
// Add a threshold for per-pixel difference to handle anti-aliasing
threshold: 0.2, // Default is 0.1
}
},
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -86,7 +91,7 @@ const config: PlaywrightTestConfig = {
},
/* Configure projects for major browsers */
projects: projects,
projects,
webServer: {
command: 'serve www -p 3333',
port: 3333,
+35 -5
View File
@@ -10,7 +10,7 @@ We intend for this icon pack to be used with [Ionic](http://ionicframework.com/)
## Contributing
Thanks for your interest in contributing! Read up on our guidelines for
[contributing](https://github.com/ionic-team/ionicons/blob/master/.github/CONTRIBUTING.md)
[contributing](https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md)
and then look through our issues with a [help wanted](https://github.com/ionic-team/ionicons/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
label.
@@ -19,14 +19,22 @@ label.
The Ionicons Web Component is an easy and performant way to use Ionicons in your app. The component will dynamically load an SVG for each icon, so your app is only requesting the icons that you need.
Also note that only visible icons are loaded, and icons which are "below the fold" and hidden from the user's view do not make fetch requests for the svg resource.
Also note that only visible icons are loaded, and icons that are "below the fold" and hidden from the user's view do not make fetch requests for the svg resource.
### Installation
If you're using [Ionic Framework](https://ionicframework.com/), Ionicons is packaged by default, so no installation is necessary. Want to use Ionicons without Ionic Framework? Place the following `<script>` near the end of your page, right before the closing </body> tag, to enable them.
If you're using [Ionic Framework](https://ionicframework.com/), Ionicons is packaged by default, so no installation is necessary. Want to use Ionicons without Ionic Framework? Place the following `<script>` near the end of your page, right before the closing `</body>` tag, to enable them.
```html
<script src="https://unpkg.com/ionicons@latest/dist/ionicons.js"></script>
<script type="module" src="https://esm.sh/ionicons@latest/loader"></script>
<script nomodule src="https://esm.sh/ionicons@latest/loader"></script>
```
you can replace `latest` to pick any version of Ionicon, e.g.:
```html
<script type="module" src="https://esm.sh/ionicons@8.0.0/loader"></script>
<script nomodule src="https://esm.sh/ionicons@8.0.0/loader"></script>
```
### Basic usage
@@ -45,6 +53,28 @@ To use a custom SVG, provide its url in the `src` attribute to request the exter
<ion-icon src="/path/to/external/file.svg"></ion-icon>
```
#### Custom Asset Path
If you have a different set of icons you would like to load or if the Ionicon icons are hosted on a different page or path, you can set the asset url from which Ionicons pulls the icons via:
```ts
import { setAssetPath, addIcons } from 'ionicons';
import { add, logoIonic, save } from 'ionicons/icons';
// set root path for loading icons to "<root>/public/svg"
setAssetPath(`${window.location.origin}/public/svg/`);
// only load specific icons
addIcons({ add, logoIonic, save });
```
This allows the use of named icons like this:
```html
<!-- now pulls the svg from "<root>/public/svg/heart.svg" -->
<ion-icon name="heart"></ion-icon>
```
## Variants
Each app icon in Ionicons has a `filled`, `outline` and `sharp` variant. These different variants are provided to make your app feel native to a variety of platforms. The filled variant uses the default name without a suffix. Note: Logo icons do not have outline or sharp variants.
@@ -55,7 +85,7 @@ Each app icon in Ionicons has a `filled`, `outline` and `sharp` variant. These d
```
### Platform specificity
When using icons in Ionic Framework you can specify different icons per platform. Use the `md` and `ios` attributes and provide the platform specific icon/variant name.
When using icons in Ionic Framework you can specify different icons per platform. Use the `md` and `ios` attributes and provide the platform-specific icon/variant name.
```html
<ion-icon ios="heart-outline" md="heart-sharp"></ion-icon>
+146 -316
View File
@@ -1,27 +1,49 @@
import path from 'node:path';
import fs from 'fs-extra';
import { join } from 'path';
import Svgo from 'svgo';
import { optimize } from 'svgo';
import { webComponentPassPlugins, sourcePassPlugins } from './plugins';
import { reservedKeywords } from './constants';
import pkgData from '../package.json' with { type: 'json' };
import type { SvgData } from './types';
async function build(rootDir: string) {
try {
const pkgJsonPath = join(rootDir, 'package.json');
const srcDir = join(rootDir, 'src');
const srcSvgDir = join(srcDir, 'svg');
const iconDir = join(rootDir, 'icons');
const distDir = join(rootDir, 'dist');
const distIoniconsDir = join(distDir, 'ionicons');
const distSvgDir = join(distDir, 'svg');
const srcDir = path.join(rootDir, 'src');
const srcSvgDir = path.join(srcDir, 'svg');
const iconDir = path.join(rootDir, 'icons');
const distDir = path.join(rootDir, 'dist');
const distIoniconsDir = path.join(distDir, 'ionicons');
const distSvgDir = path.join(distDir, 'svg');
const optimizedSvgDir = path.join(distIoniconsDir, 'svg');
await Promise.all([fs.emptyDir(iconDir), fs.emptyDir(distDir)]);
await fs.emptyDir(distSvgDir), await fs.emptyDir(distIoniconsDir);
/**
* Create the directories first, then empty them
* This ensures they exist before we try to write files to them
*/
await Promise.all([
fs.ensureDir(iconDir),
fs.ensureDir(distDir),
fs.ensureDir(distSvgDir),
fs.ensureDir(optimizedSvgDir),
fs.ensureDir(distIoniconsDir),
]);
/**
* Empty the directories
*/
await Promise.all([
fs.emptyDir(iconDir),
fs.emptyDir(distDir),
fs.emptyDir(distSvgDir),
fs.emptyDir(optimizedSvgDir),
fs.emptyDir(distIoniconsDir),
]);
const pkgData = await fs.readJson(pkgJsonPath);
const version = pkgData.version as string;
const srcSvgData = await getSvgs(srcSvgDir, distSvgDir, distIoniconsDir);
const srcSvgData = await getSvgs(srcSvgDir, distSvgDir, optimizedSvgDir);
await optimizeSvgs(srcSvgData);
await Promise.all([
createDataJson(version, srcDir, distDir, srcSvgData),
createIconPackage(version, iconDir, srcSvgData),
@@ -30,7 +52,7 @@ async function build(rootDir: string) {
const svgSymbolsContent = await createSvgSymbols(version, distDir, srcSvgData);
await createCheatsheet(version, rootDir, distDir, svgSymbolsContent, srcSvgData);
await createWebTypes(version, rootDir, distDir, srcSvgData);
await copyToTesting(rootDir, distDir, srcSvgData);
} catch (e) {
console.error(e);
@@ -39,169 +61,84 @@ async function build(rootDir: string) {
}
async function optimizeSvgs(srcSvgData: SvgData[]) {
// https://github.com/svg/svgo
const optimizePass = new Svgo({});
const webComponentPass = new Svgo({
full: true,
plugins: [
{
addFillNoneCss: {
type: 'perItem',
fn: (item, params) => {
if (!Array.isArray(params.attrs)) {
params.attrs = [params.attrs];
}
if (item.isElem()) {
item.eachAttr((attr) => {
if (attr.name === 'fill') {
if (attr.value === 'none') {
item.class.add('ionicon-fill-none');
}
item.removeAttr('fill');
} else if (attr.name === 'stroke') {
item.removeAttr('stroke');
} else if (attr.name === 'stroke-width' && attr.value === '32') {
item.removeAttr('stroke-width');
item.class.add('ionicon-stroke-width');
}
});
}
},
},
} as any,
{
removeStyleElement: true,
},
{
removeScriptElement: true,
},
{
removeDimensions: true,
},
],
});
const sourcePass = new Svgo({
full: true,
plugins: [
{
addFillNoneCss: {
type: 'perItem',
fn: (item, params) => {
if (!Array.isArray(params.attrs)) {
params.attrs = [params.attrs];
}
if (item.isElem()) {
item.eachAttr((attr) => {
if (attr.name === 'stroke' || attr.name === 'fill') {
if (attr.value === '#000' || attr.value === 'currentColor') {
item.addAttr({
name: attr.name,
value: 'currentColor',
prefix: '',
local: attr.name,
});
} else if (attr.value !== 'none') {
throw new Error(`invalid "${attr.name}" value: ${attr.value}`);
}
}
});
}
},
},
} as any,
{
removeStyleElement: true,
},
{
removeScriptElement: true,
},
{
removeDimensions: true,
},
],
});
const validatePass = new Svgo({
full: true,
plugins: [
{
addFillNoneCss: {
type: 'perItem',
fn: (item, params) => {
if (!Array.isArray(params.attrs)) {
params.attrs = [params.attrs];
}
if (item.isElem()) {
item.eachAttr((attr) => {
if (attr.name === 'style') {
throw new Error('Inline style attributed detected');
}
});
}
if (item.isElem('style')) {
throw new Error('Inline style element detected');
}
},
},
} as any,
],
});
await Promise.all(
srcSvgData.map(async (svgData) => {
return optimizeSvg(optimizePass, webComponentPass, sourcePass, validatePass, svgData);
return optimizeSvg(svgData);
}),
);
}
async function optimizeSvg(
optimizePass: Svgo,
webComponentPass: Svgo,
sourcePass: Svgo,
validatePass: Svgo,
svgData: SvgData,
) {
async function optimizeSvg(svgData: SvgData) {
const srcSvgContent = await fs.readFile(svgData.srcFilePath, 'utf8');
const optimizedSvg = await optimizePass.optimize(srcSvgContent, { path: svgData.srcFilePath });
const optimizedSvg = await optimize(srcSvgContent, { path: svgData.srcFilePath });
const webComponentSvg = await optimize(optimizedSvg.data, {
path: svgData.srcFilePath,
plugins: webComponentPassPlugins,
});
const sourceSvg = await optimize(optimizedSvg.data, {
path: svgData.srcFilePath,
plugins: sourcePassPlugins,
});
const optimizedCode = optimizedSvg.data.replace(
/<svg (.*?)>/,
`<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">`,
);
const webComponentSvg = await webComponentPass.optimize(optimizedCode, { path: svgData.srcFilePath });
const sourceSvg = await sourcePass.optimize(optimizedCode, { path: svgData.srcFilePath });
// Ensure directories exist before writing files
await Promise.all([
fs.ensureDir(path.dirname(svgData.optimizedFilePath)),
fs.ensureDir(path.dirname(svgData.distSvgFilePath)),
]);
svgData.optimizedSvgContent = webComponentSvg.data;
try {
await validatePass.optimize(svgData.optimizedSvgContent, { path: svgData.srcFilePath });
} catch (e) {
console.error(`${e.message}: ${svgData.srcFilePath}`);
}
await fs.writeFile(svgData.optimizedFilePath, svgData.optimizedSvgContent);
await fs.writeFile(svgData.distSvgFilePath, sourceSvg.data);
await Promise.all([
fs.writeFile(svgData.optimizedFilePath, svgData.optimizedSvgContent),
fs.writeFile(svgData.distSvgFilePath, sourceSvg.data),
]);
}
async function copyToTesting(rootDir: string, distDir: string, srcSvgData: SvgData[]) {
const testDir = join(rootDir, 'www');
const testBuildDir = join(testDir, 'build');
const testSvgDir = join(testBuildDir, 'svg');
await fs.ensureDir(testSvgDir);
const testDir = path.join(rootDir, 'www');
const testBuildDir = path.join(testDir, 'build');
const testSvgDir = path.join(testBuildDir, 'svg');
const cheatsheetDir = path.join(testDir, 'icon', 'test', 'cheatsheet');
const version = (await fs.readJson(path.join(rootDir, 'package.json'))).version;
// Ensure all directories exist
await Promise.all([
fs.ensureDir(testDir),
fs.ensureDir(testBuildDir),
fs.ensureDir(testSvgDir),
fs.ensureDir(cheatsheetDir),
]);
await Promise.all(
srcSvgData.map(async (svgData) => {
const testSvgFilePath = join(testSvgDir, svgData.fileName);
await fs.writeFile(testSvgFilePath, svgData.optimizedSvgContent);
}),
srcSvgData
.filter((svgData): svgData is SvgData & { optimizedSvgContent: string } => Boolean(svgData.optimizedSvgContent))
.map(async (svgData) => {
const testSvgFilePath = path.join(testSvgDir, svgData.fileName);
await fs.writeFile(testSvgFilePath, svgData.optimizedSvgContent);
}),
);
const distCheatsheetFilePath = join(distDir, 'cheatsheet.html');
const testCheatsheetFilePath = join(testDir, 'cheatsheet.html');
await fs.copyFile(distCheatsheetFilePath, testCheatsheetFilePath);
const wwwCheatsheetFilePath = path.join(cheatsheetDir, 'index.html');
const srcIndexFilePath = path.join(rootDir, 'src', 'components', 'icon', 'test', 'index.html');
const testIndexFilePath = path.join(testDir, 'index.html');
await fs.copyFile(srcIndexFilePath, testIndexFilePath);
// Generate the cheatsheet with placeholders filled in
const svgSymbolsContent = await fs.readFile(path.join(distDir, 'ionicons.symbols.svg'), 'utf8');
const c = srcSvgData.map(
(svgData) =>
`<a href="/svg/${svgData.fileName}"><svg><use href="#${svgData.iconName}" xlink:href="#${svgData.iconName}"/></svg></a>`,
);
c.push(svgSymbolsContent);
const cheatsheetTemplate = await fs.readFile(path.join(rootDir, 'scripts', 'cheatsheet-template.html'), 'utf8');
const cheatsheetHtml = cheatsheetTemplate
.replace(/{{version}}/g, version)
.replace(/{{count}}/g, srcSvgData.length.toString())
.replace(/{{content}}/g, c.join('\n'));
await fs.writeFile(wwwCheatsheetFilePath, cheatsheetHtml);
}
async function createSvgSymbols(version: string, distDir: string, srcSvgData: SvgData[]) {
@@ -211,7 +148,7 @@ async function createSvgSymbols(version: string, distDir: string, srcSvgData: Sv
return 0;
});
const symbolsSvgFilePath = join(distDir, 'ionicons.symbols.svg');
const symbolsSvgFilePath = path.join(distDir, 'ionicons.symbols.svg');
const lines = [
`<svg data-ionicons="${version}" style="display:none">`,
@@ -229,19 +166,19 @@ async function createSvgSymbols(version: string, distDir: string, srcSvgData: Sv
`</style>`,
];
srcSvgData.forEach((svgData) => {
const svg = svgData.optimizedSvgContent
.replace(`<svg xmlns="http://www.w3.org/2000/svg"`, `<symbol id="${svgData.iconName}"`)
.replace(`</svg>`, `</symbol>`);
lines.push(svg);
});
srcSvgData
.filter((svgData): svgData is SvgData & { optimizedSvgContent: string } => Boolean(svgData.optimizedSvgContent))
.forEach((svgData) => {
const svg = svgData.optimizedSvgContent
.replace(`<svg xmlns="http://www.w3.org/2000/svg"`, `<symbol id="${svgData.iconName}"`)
.replace(`</svg>`, `</symbol>`);
lines.push(svg);
});
lines.push(`</svg>`, ``);
const content = lines.join('\n');
await fs.writeFile(symbolsSvgFilePath, content);
return content;
}
@@ -252,11 +189,12 @@ async function createCheatsheet(
svgSymbolsContent: string,
srcSvgData: SvgData[],
) {
const CheatsheetTmpFilePath = join(rootDir, 'scripts', 'cheatsheet-template.html');
const distCheatsheetFilePath = join(distDir, 'cheatsheet.html');
const CheatsheetTmpFilePath = path.join(rootDir, 'scripts', 'cheatsheet-template.html');
const distCheatsheetFilePath = path.join(distDir, 'cheatsheet.html');
const c = srcSvgData.map(
(svgData) => `<a href="./svg/${svgData.fileName}"><svg><use href="#${svgData.iconName}" xlink:href="#${svgData.iconName}"/></svg></a>`,
(svgData) =>
`<a href="/svg/${svgData.fileName}"><svg><use href="#${svgData.iconName}" xlink:href="#${svgData.iconName}"/></svg></a>`,
);
c.push(svgSymbolsContent);
@@ -269,10 +207,26 @@ async function createCheatsheet(
await fs.writeFile(distCheatsheetFilePath, html);
}
async function getSvgs(srcSvgDir: string, distSvgDir: string, distIoniconsDir: string): Promise<SvgData[]> {
const optimizedSvgDir = join(distIoniconsDir, 'svg');
await fs.emptyDir(optimizedSvgDir);
async function createWebTypes(version: string, rootDir: string, distDir: string, srcSvgData: SvgData[]) {
const srcWebTypeFilePath = path.join(rootDir, 'src/ionicons.web-types.json');
const distWebTypesFilePath = path.join(distDir, 'ionicons.web-types.json');
const webTypes = JSON.parse(await fs.readFile(srcWebTypeFilePath, 'utf8'));
webTypes.version = version;
const icons = webTypes.contributions.html.ionicons;
for (let data of srcSvgData) {
icons.push({
name: data.iconName,
icon: 'dist/svg/' + data.fileName,
});
}
const jsonStr = JSON.stringify(webTypes, null, 2) + '\n';
await fs.writeFile(distWebTypesFilePath, jsonStr);
}
async function getSvgs(srcSvgDir: string, distSvgDir: string, optimizedSvgDir: string): Promise<SvgData[]> {
const svgFiles = (await fs.readdir(srcSvgDir)).filter((fileName) => {
return !fileName.startsWith('.') && fileName.endsWith('.svg');
});
@@ -286,13 +240,13 @@ async function getSvgs(srcSvgDir: string, distSvgDir: string, distIoniconsDir: s
}
// srcFilePath: /src/svg/airplane-outline.svg
const srcFilePath = join(srcSvgDir, fileName);
const srcFilePath = path.join(srcSvgDir, fileName);
// srcFilePath: /src/svg/airplane-outline.svg
const distSvgFilePath = join(distSvgDir, fileName);
const distSvgFilePath = path.join(distSvgDir, fileName);
// optimizedFilePath: /dist/ionicons/svg/airplane-outline.svg
const optimizedFilePath = join(optimizedSvgDir, fileName);
const optimizedFilePath = path.join(optimizedSvgDir, fileName);
const dotSplit = fileName.split('.');
if (dotSplit.length > 2) {
@@ -326,7 +280,6 @@ async function getSvgs(srcSvgDir: string, distSvgDir: string, distIoniconsDir: s
distSvgFilePath,
srcSvgContent: await fs.readFile(srcFilePath, 'utf8'),
optimizedFilePath,
optimizedSvgContent: null,
iconName,
fileNameMjs,
fileNameCjs,
@@ -343,29 +296,15 @@ async function getSvgs(srcSvgDir: string, distSvgDir: string, distIoniconsDir: s
}
async function createIconPackage(version: string, iconDir: string, srcSvgData: SvgData[]) {
const iconPkgJsonFilePath = join(iconDir, 'package.json');
await Promise.all([
createEsmIcons(version, iconDir, srcSvgData),
createCjsIcons(version, iconDir, srcSvgData),
createDtsIcons(version, iconDir, srcSvgData),
]);
const iconPkgJson = {
name: 'ionicons/icons',
version,
module: 'index.mjs',
main: 'index.js',
typings: 'index.d.ts',
private: true,
};
const jsonStr = JSON.stringify(iconPkgJson, null, 2) + '\n';
await fs.writeFile(iconPkgJsonFilePath, jsonStr);
}
async function createEsmIcons(version: string, iconDir: string, srcSvgData: SvgData[]) {
const iconEsmFilePath = join(iconDir, 'index.mjs');
const iconEsmFilePath = path.join(iconDir, 'index.mjs');
const o = [`/* Ionicons v${version}, ES Modules */`, ``];
@@ -377,7 +316,7 @@ async function createEsmIcons(version: string, iconDir: string, srcSvgData: SvgD
}
async function createCjsIcons(version: string, iconDir: string, srcSvgData: SvgData[]) {
const iconCjsFilePath = join(iconDir, 'index.js');
const iconCjsFilePath = path.join(iconDir, 'index.js');
const o = [`/* Ionicons v${version}, CommonJS */`, ``];
@@ -389,7 +328,7 @@ async function createCjsIcons(version: string, iconDir: string, srcSvgData: SvgD
}
async function createDtsIcons(version: string, iconDir: string, srcSvgData: SvgData[]) {
const iconDtsFilePath = join(iconDir, 'index.d.ts');
const iconDtsFilePath = path.join(iconDir, 'index.d.ts');
const o = [`/* Ionicons v${version}, Types */`, ``];
@@ -402,6 +341,11 @@ async function createDtsIcons(version: string, iconDir: string, srcSvgData: SvgD
function getDataUrl(svgData: SvgData) {
let svg = svgData.optimizedSvgContent;
if (!svg) {
throw new Error(`oh no! no optimized SVG content! ${svgData.fileName}`);
}
if (svg.includes(`'`)) {
throw new Error(`oh no! no single quotes allowed! ${svgData.fileName}`);
}
@@ -413,17 +357,10 @@ function getDataUrl(svgData: SvgData) {
}
async function createDataJson(version: string, srcDir: string, distDir: string, srcSvgData: SvgData[]) {
const srcDataJsonPath = join(srcDir, 'data.json');
const distDataJsonPath = join(distDir, 'ionicons.json');
let data: JsonData;
try {
data = await fs.readJson(srcDataJsonPath);
} catch (e) {
data = {} as any;
}
const srcDataJsonPath = path.join(srcDir, 'data.json');
const distDataJsonPath = path.join(distDir, 'ionicons.json');
const data = await fs.readJson(srcDataJsonPath).catch(() => ({}));
data.icons = data.icons || [];
// add new icons
@@ -472,60 +409,6 @@ function upFirst(word: string) {
return word[0].toUpperCase() + word.toLowerCase().slice(1);
}
interface SvgData {
/**
* airplane-outline.svg
*/
fileName: string;
/**
* airplane
*/
title: string;
/**
* /src/svg/airplane-outline.svg
*/
srcFilePath: string;
/**
* /dist/ionicons/svg/airplane-outline.svg
*/
optimizedFilePath: string;
/**
* /dist/svg/airplane-outline.svg
*/
distSvgFilePath: string;
optimizedSvgContent: string;
/**
* airplane-outline
*/
iconName: string;
/**
* airplane-outline.mjs
*/
fileNameMjs: string;
/**
* airplane-outline.js
*/
fileNameCjs: string;
/**
* airplaneOutline
*/
exportName: string;
}
interface JsonData {
icons: { name: string; tags?: string[] }[];
version?: string;
}
function toTitleCase(str: string) {
const s = str.trim().toLowerCase().split(' ');
for (var i = 0; i < s.length; i++) {
@@ -534,58 +417,5 @@ function toTitleCase(str: string) {
return s.join(' ');
}
// https://mathiasbynens.be/notes/reserved-keywords
const reservedKeywords = new Set([
'do',
'if',
'in',
'for',
'let',
'new',
'try',
'var',
'case',
'else',
'enum',
'eval',
'null',
'this',
'true',
'void',
'with',
'await',
'break',
'catch',
'class',
'const',
'false',
'super',
'throw',
'while',
'yield',
'delete',
'export',
'import',
'public',
'return',
'static',
'switch',
'typeof',
'default',
'extends',
'finally',
'package',
'private',
'continue',
'debugger',
'function',
'arguments',
'interface',
'protected',
'implements',
'instanceof',
'constructor',
]);
// let's do this
build(join(__dirname, '..'));
build(path.join(__dirname, '..'));
+23 -27
View File
@@ -1,24 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ionicons {{version}} Cheatsheet</title>
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Ionicons {{version}} Cheatsheet</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
</head>
<body>
<test-header></test-header>
<main>
<h1>Ionicons {{version}} Cheatsheet</h1>
<h3>{{count}} icons</h3>
{{content}}
</main>
</body>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background: #fff;
}
h1 {
margin: 0;
}
.options {
padding: 15px 0 20px 0;
}
label {
display: inline-block;
width: 100px;
font-size: 12px;
}
svg {
width: 32px;
height: 32px;
@@ -31,11 +34,4 @@
opacity: 0.7;
}
</style>
</head>
<body>
<h1>Ionicons {{version}} Cheatsheet</h1>
<h3>{{count}} icons</h3>
{{content}}
</body>
</html>
-12
View File
@@ -29,18 +29,6 @@ async function collectionCopy(rootDir: string) {
};
await fs.writeFile(cePackageJsonPath, JSON.stringify(cePackageJson, null, 2));
/**
* TODO: Remove this in Ionicons v6.0
* Stencil 2 removed the legacy loader,
* but that is what Ionicons users were using
* to load Ionicons from a CDN. The lines
* below will add in a legacy loader for users
* to use so there is no breaking change in usage.
*/
const installLoaderSrc = join(rootDir, 'scripts', 'install-loader.js');
const installLoaderDest = join(rootDir, 'dist', 'ionicons.js');
await fs.copyFile(installLoaderSrc, installLoaderDest)
// this is temporary!!!!
// removing the `type` from the d.ts export
// to make it easier for users migrating between
+52
View File
@@ -0,0 +1,52 @@
// https://mathiasbynens.be/notes/reserved-keywords
export const reservedKeywords = new Set([
'do',
'if',
'in',
'for',
'let',
'new',
'try',
'var',
'case',
'else',
'enum',
'eval',
'null',
'this',
'true',
'void',
'with',
'await',
'break',
'catch',
'class',
'const',
'false',
'super',
'throw',
'while',
'yield',
'delete',
'export',
'import',
'public',
'return',
'static',
'switch',
'typeof',
'default',
'extends',
'finally',
'package',
'private',
'continue',
'debugger',
'function',
'arguments',
'interface',
'protected',
'implements',
'instanceof',
'constructor',
]);
-30
View File
@@ -1,30 +0,0 @@
(function(doc){
var scriptElm = doc.scripts[doc.scripts.length - 1];
var warn = ['[ionicons] Deprecated script, please remove: ' + scriptElm.outerHTML];
warn.push('To improve performance it is recommended to set the differential scripts in the head as follows:')
var parts = scriptElm.src.split('/');
parts.pop();
parts.push('ionicons');
var url = parts.join('/');
var scriptElm = doc.createElement('script');
scriptElm.setAttribute('type', 'module');
scriptElm.src = url + '/ionicons.esm.js';
warn.push(scriptElm.outerHTML);
scriptElm.setAttribute('data-stencil-namespace', 'ionicons');
doc.head.appendChild(scriptElm);
scriptElm = doc.createElement('script');
scriptElm.setAttribute('nomodule', '');
scriptElm.src = url + '/ionicons.js';
warn.push(scriptElm.outerHTML);
scriptElm.setAttribute('data-stencil-namespace', 'ionicons');
doc.head.appendChild(scriptElm)
console.warn(warn.join('\n'));
})(document);
+87
View File
@@ -0,0 +1,87 @@
import { PluginConfig } from 'svgo';
const setRootIoniconClass: PluginConfig = {
name: 'addClassesToSVGElement',
params: {
className: 'ionicon',
},
};
const addFillNoneCss: PluginConfig = {
name: 'addFillNoneCss',
fn: () => ({
element: {
enter: (element) => {
if (element.attributes.fill) {
if (element.attributes.fill === 'none') {
element.attributes.class = [...(element.attributes.class?.split(' ') || []), 'ionicon-fill-none'].join(' ');
}
delete element.attributes.fill;
}
if (element.attributes.stroke) {
delete element.attributes.stroke;
}
if (
element.attributes['stroke-width'] &&
(element.attributes['stroke-width'] === '32px' || element.attributes['stroke-width'] === '32')
) {
delete element.attributes['stroke-width'];
element.attributes.class = [...(element.attributes.class?.split(' ') || []), 'ionicon-stroke-width'].join(
' ',
);
}
},
},
}),
};
const forceCurrentColor: PluginConfig = {
name: 'forceCurrentColor',
fn: () => ({
element: {
enter: (element) => {
const attr = element.attributes.stroke || element.attributes.fill;
const attrName = element.attributes.stroke ? 'stroke' : element.attributes.fill ? 'fill' : undefined;
if (attrName) {
if (attr === '#000' || attr === 'currentColor') {
element.attributes[attrName] = 'currentColor';
} else if (attr !== 'none') {
throw new Error(`invalid "${attrName}" value: ${element.attributes[attrName]}`);
}
}
},
},
}),
};
const validatePlugin: PluginConfig = {
name: 'validate',
fn: () => ({
element: {
enter: (element) => {
if (element.attributes.style) {
console.warn(
`Inline style attributed detected: <${element.name} style="${element.attributes.style}">...</${element.name}>`,
);
}
if (element.name === 'style') {
console.warn('Inline style element detected');
}
},
},
}),
};
const basePlugins: PluginConfig[] = [
'removeStyleElement',
'convertStyleToAttrs',
'removeScripts',
'removeDimensions',
setRootIoniconClass,
validatePlugin,
];
export const webComponentPassPlugins: PluginConfig[] = [...basePlugins, addFillNoneCss];
export const sourcePassPlugins: PluginConfig[] = [...basePlugins, forceCurrentColor];
+13 -16
View File
@@ -4,38 +4,35 @@
The `src/svg` directory is the single source of truth for svgs. They should not already be optimized and can be the original svg export straight out of an svg editor. A build step before releasing will optimize the source svgs (remove comments, reduce the size, etc) and ensure they'll work within `ion-icon`.
## Build Locally
After an svg has been updated, added or deleted from the `src/svg` directory, run:
npm run build
```sh
npm run build
```
The build command will optimize all of the icons and generate the files to be distributed. After the build command, all of the optimized svgs are saved in `dist/ionicons/svg`. Additionally the `dist` directory contains the distribution files for the `ion-icon` web component.
## Svg Symbols Cheatsheet
After a build, a new `www/cheatsheet.html` file will be created. This version uses svg symbols rather than `ion-icon`.
## ion-icon Component Preview
To see the `ion-icon` component in action, run:
npm start
```sh
npm start
```
## Release Steps
npm run release.prepare
Releases are automated via GitHub Actions. To trigger a release:
The release script will ask what version to use. After the script completes, double check the `www/cheatsheet.html` to ensure everything is good to go.
Next, update `CHANGELOG.md`, then commit and push your changes Github.
Next run:
npm run release
Triple check the version number is correct, and choose which tag this should be released as. If it's a pre-release, it should be `dev`.
1. Go to the [Release Orchestrator](https://github.com/ionic-team/ionicons/actions/workflows/release-orchestrator.yml) workflow
2. Click "Run workflow"
3. Select the release type:
- **dev** — Creates a pre-release with a timestamp-based version (e.g., `8.0.14-dev.11784821417.1c794397`)
- **production** — Creates a semver release; select `patch`, `minor`, or `major`
4. The workflow will build, publish to NPM, and create a GitHub release (for production releases)
-7
View File
@@ -1,7 +0,0 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"target": "es2017"
}
}
+53
View File
@@ -0,0 +1,53 @@
import { PluginConfig } from 'svgo';
export interface SvgData {
/**
* airplane-outline.svg
*/
fileName: string;
/**
* airplane
*/
title: string;
/**
* /src/svg/airplane-outline.svg
*/
srcFilePath: string;
/**
* /dist/ionicons/svg/airplane-outline.svg
*/
optimizedFilePath: string;
/**
* /dist/svg/airplane-outline.svg
*/
distSvgFilePath: string;
/**
* optimized svg content
*/
optimizedSvgContent?: string;
/**
* airplane-outline
*/
iconName: string;
/**
* airplane-outline.mjs
*/
fileNameMjs: string;
/**
* airplane-outline.js
*/
fileNameCjs: string;
/**
* airplaneOutline
*/
exportName: string;
}
+23 -4
View File
@@ -25,6 +25,7 @@ export namespace Components {
"ios"?: string;
/**
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`.
* @default false
*/
"lazy": boolean;
/**
@@ -33,6 +34,7 @@ export namespace Components {
"md"?: string;
/**
* The mode determines which platform styles to use.
* @default getIonMode()
*/
"mode": string;
/**
@@ -40,7 +42,7 @@ export namespace Components {
*/
"name"?: string;
/**
* When set to `false`, SVG content that is HTTP fetched will not be checked if the response SVG content has any `<script>` elements, or any attributes that start with `on`, such as `onclick`.
* When `true`, SVG content, including SVG `data:` URLs, is checked before it renders. SVGs with `<script>` elements, attributes that start with `on` (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered, and `<foreignObject>` elements are removed. Only set this to `false` for SVG content from a trusted source.
* @default true
*/
"sanitize": boolean;
@@ -85,6 +87,7 @@ declare namespace LocalJSX {
"ios"?: string;
/**
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`.
* @default false
*/
"lazy"?: boolean;
/**
@@ -93,6 +96,7 @@ declare namespace LocalJSX {
"md"?: string;
/**
* The mode determines which platform styles to use.
* @default getIonMode()
*/
"mode"?: string;
/**
@@ -100,7 +104,7 @@ declare namespace LocalJSX {
*/
"name"?: string;
/**
* When set to `false`, SVG content that is HTTP fetched will not be checked if the response SVG content has any `<script>` elements, or any attributes that start with `on`, such as `onclick`.
* When `true`, SVG content, including SVG `data:` URLs, is checked before it renders. SVGs with `<script>` elements, attributes that start with `on` (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered, and `<foreignObject>` elements are removed. Only set this to `false` for SVG content from a trusted source.
* @default true
*/
"sanitize"?: boolean;
@@ -113,15 +117,30 @@ declare namespace LocalJSX {
*/
"src"?: string;
}
interface IonIconAttributes {
"mode": string;
"color": string;
"ios": string;
"md": string;
"flipRtl": boolean;
"name": string;
"src": string;
"icon": string;
"size": string;
"lazy": boolean;
"sanitize": boolean;
}
interface IntrinsicElements {
"ion-icon": IonIcon;
"ion-icon": Omit<IonIcon, keyof IonIconAttributes> & { [K in keyof IonIcon & keyof IonIconAttributes]?: IonIcon[K] } & { [K in keyof IonIcon & keyof IonIconAttributes as `attr:${K}`]?: IonIconAttributes[K] } & { [K in keyof IonIcon & keyof IonIconAttributes as `prop:${K}`]?: IonIcon[K] };
}
}
export { LocalJSX as JSX };
declare module "@stencil/core" {
export namespace JSX {
interface IntrinsicElements {
"ion-icon": LocalJSX.IonIcon & JSXBase.HTMLAttributes<HTMLIonIconElement>;
"ion-icon": LocalJSX.IntrinsicElements["ion-icon"] & JSXBase.HTMLAttributes<HTMLIonIconElement>;
}
}
}

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 512 B

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 227 B

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

Before

Width:  |  Height:  |  Size: 1000 B

After

Width:  |  Height:  |  Size: 1000 B

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 369 B

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

Before

Width:  |  Height:  |  Size: 372 B

After

Width:  |  Height:  |  Size: 372 B

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 233 B

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 340 B

+21 -4
View File
@@ -4,12 +4,13 @@
width: 1em;
height: 1em;
contain: strict;
font-size: 1em;
contain: layout style;
fill: currentColor;
box-sizing: content-box !important;
}
:host .ionicon {
@@ -21,11 +22,19 @@
}
.ionicon-stroke-width {
stroke-width: 32px;
stroke-width: var(--ionicon-stroke-width, 32px);
}
.icon-inner,
.icon-inner {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.ionicon,
svg {
display: block;
@@ -34,6 +43,14 @@ svg {
width: 100%;
}
/* Slotted Content
* -----------------------------------------------------------
*/
::slotted(*) {
font-size: inherit !important;
}
/* Icon RTL
* -----------------------------------------------------------
*/
+83 -31
View File
@@ -1,5 +1,5 @@
import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';
import { getSvgContent, ioniconContent } from './request';
import { getCacheKey, getSvgContent, ioniconContent } from './request';
import { getName, getUrl, inheritAttributes, isRTL } from './utils';
@Component({
@@ -74,9 +74,11 @@ export class Icon {
@Prop() lazy = false;
/**
* When set to `false`, SVG content that is HTTP fetched will not be checked
* if the response SVG content has any `<script>` elements, or any attributes
* that start with `on`, such as `onclick`.
* When `true`, SVG content, including SVG `data:` URLs, is checked before it
* renders. SVGs with `<script>` elements, attributes that start with `on`
* (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered,
* and `<foreignObject>` elements are removed. Only set this to `false` for
* SVG content from a trusted source.
* @default true
*/
@Prop() sanitize = true;
@@ -86,15 +88,20 @@ export class Icon {
}
connectedCallback() {
// purposely do not return the promise here because loading
// the svg file should not hold up loading the app
// only load the svg if it's visible
/**
* purposely do not return the promise here because loading
* the svg file should not hold up loading the app
* only load the svg if it's visible
*/
this.waitUntilVisible(this.el, '50px', () => {
this.isVisible = true;
this.loadIcon();
});
}
/**
* Loads the icon after the component has finished rendering.
*/
componentDidLoad() {
/**
* Addresses an Angular issue where property values are assigned after the 'connectedCallback' but prior to the registration of watchers.
@@ -107,33 +114,59 @@ export class Icon {
}
}
/**
* Disconnect the IntersectionObserver.
*/
disconnectedCallback() {
if (this.io) {
this.io.disconnect();
this.io = undefined;
}
}
private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {
if (Build.isBrowser && this.lazy && typeof window !== 'undefined' && (window as any).IntersectionObserver) {
const io = (this.io = new (window as any).IntersectionObserver(
(data: IntersectionObserverEntry[]) => {
if (data[0].isIntersecting) {
io.disconnect();
this.io = undefined;
cb();
}
},
{ rootMargin },
));
io.observe(el);
} else {
// browser doesn't support IntersectionObserver
// so just fallback to always show it
cb();
/**
* Wait until the icon is visible in the viewport.
* @param el - The element to observe.
* @param rootMargin - The root margin of the observer.
* @param cb - The callback to call when the element is visible.
*/
private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {
/**
* IntersectionObserver is a browser API that allows you to observe
* the visibility of an element relative to a root element. It is
* supported in all modern browsers, except IE and when server-side
* rendering.
*/
const hasIntersectionObserverSupport = Boolean(
Build.isBrowser && this.lazy && typeof window !== 'undefined' && window.IntersectionObserver,
);
/**
* browser doesn't support IntersectionObserver
* so just fallback to always show it
*/
if (!hasIntersectionObserverSupport) {
return cb();
}
const io = (this.io = new window.IntersectionObserver(
(data: IntersectionObserverEntry[]) => {
if (data[0].isIntersecting) {
io.disconnect();
this.io = undefined;
cb();
}
},
{ rootMargin },
));
io.observe(el);
}
/**
* Watch for changes to the icon name, src, icon, ios, or md properties.
* When a change is detected, the icon will be loaded.
*/
@Watch('name')
@Watch('src')
@Watch('icon')
@@ -144,12 +177,13 @@ export class Icon {
const url = getUrl(this);
if (url) {
if (ioniconContent.has(url)) {
const cacheKey = getCacheKey(url, this.sanitize);
if (ioniconContent.has(cacheKey)) {
// sync if it's already loaded
this.svgContent = ioniconContent.get(url);
this.svgContent = ioniconContent.get(cacheKey);
} else {
// async if it hasn't been loaded
getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(url)));
getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(cacheKey)));
}
this.didLoadIcon = true;
}
@@ -161,11 +195,18 @@ export class Icon {
render() {
const { flipRtl, iconName, inheritedAttributes, el } = this;
const mode = this.mode || 'md';
// we have designated that arrows & chevrons should automatically flip (unless flip-rtl is set to false) because "back" is left in ltr and right in rtl, and "forward" is the opposite
/**
* we have designated that arrows & chevrons should automatically flip (unless flip-rtl
* is set to false) because "back" is left in ltr and right in rtl, and "forward" is the opposite
*/
const shouldAutoFlip = iconName
? (iconName.includes('arrow') || iconName.includes('chevron')) && flipRtl !== false
: false;
// if shouldBeFlippable is true, the icon should change direction when `dir` changes
/**
* if shouldBeFlippable is true, the icon should change direction when `dir` changes
*/
const shouldBeFlippable = flipRtl || shouldAutoFlip;
return (
@@ -176,23 +217,34 @@ export class Icon {
...createColorClasses(this.color),
[`icon-${this.size}`]: !!this.size,
'flip-rtl': shouldBeFlippable,
'icon-rtl': shouldBeFlippable && isRTL(el)
'icon-rtl': shouldBeFlippable && isRTL(el),
}}
{...inheritedAttributes}
>
{Build.isBrowser && this.svgContent ? (
<div class="icon-inner" innerHTML={this.svgContent}></div>
) : (
<div class="icon-inner"></div>
<div class="icon-inner">
<slot></slot>
</div>
)}
</Host>
);
}
}
/**
* Get the mode of the document.
* @returns The mode of the document.
*/
const getIonMode = () =>
(Build.isBrowser && typeof document !== 'undefined' && document.documentElement.getAttribute('mode')) || 'md';
/**
* Create color classes for the icon.
* @param color - The color of the icon.
* @returns The color classes for the icon.
*/
const createColorClasses = (color: string | undefined) => {
return color
? {
+13 -13
View File
@@ -7,19 +7,19 @@
## Properties
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------- |
| `color` | `color` | The color to use for the background of the item. | `string \| undefined` | `undefined` |
| `flipRtl` | `flip-rtl` | Specifies whether the icon should horizontally flip when `dir` is `"rtl"`. | `boolean \| undefined` | `undefined` |
| `icon` | `icon` | A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property. | `any` | `undefined` |
| `ios` | `ios` | Specifies which icon to use on `ios` mode. | `string \| undefined` | `undefined` |
| `lazy` | `lazy` | If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`. | `boolean` | `false` |
| `md` | `md` | Specifies which icon to use on `md` mode. | `string \| undefined` | `undefined` |
| `mode` | `mode` | The mode determines which platform styles to use. | `string` | `getIonMode()` |
| `name` | `name` | Specifies which icon to use from the built-in set of icons. | `string \| undefined` | `undefined` |
| `sanitize` | `sanitize` | When set to `false`, SVG content that is HTTP fetched will not be checked if the response SVG content has any `<script>` elements, or any attributes that start with `on`, such as `onclick`. | `boolean` | `true` |
| `size` | `size` | The size of the icon. Available options are: `"small"` and `"large"`. | `string \| undefined` | `undefined` |
| `src` | `src` | Specifies the exact `src` of an SVG file to use. | `string \| undefined` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------- |
| `color` | `color` | The color to use for the background of the item. | `string \| undefined` | `undefined` |
| `flipRtl` | `flip-rtl` | Specifies whether the icon should horizontally flip when `dir` is `"rtl"`. | `boolean \| undefined` | `undefined` |
| `icon` | `icon` | A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property. | `any` | `undefined` |
| `ios` | `ios` | Specifies which icon to use on `ios` mode. | `string \| undefined` | `undefined` |
| `lazy` | `lazy` | If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`. | `boolean` | `false` |
| `md` | `md` | Specifies which icon to use on `md` mode. | `string \| undefined` | `undefined` |
| `mode` | `mode` | The mode determines which platform styles to use. | `string` | `getIonMode()` |
| `name` | `name` | Specifies which icon to use from the built-in set of icons. | `string \| undefined` | `undefined` |
| `sanitize` | `sanitize` | When `true`, SVG content, including SVG `data:` URLs, is checked before it renders. SVGs with `<script>` elements, attributes that start with `on` (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered, and `<foreignObject>` elements are removed. Only set this to `false` for SVG content from a trusted source. | `boolean` | `true` |
| `size` | `size` | The size of the icon. Available options are: `"small"` and `"large"`. | `string \| undefined` | `undefined` |
| `src` | `src` | Specifies the exact `src` of an SVG file to use. | `string \| undefined` | `undefined` |
----------------------------------------------
+99 -45
View File
@@ -5,53 +5,107 @@ const requests = new Map<string, Promise<any>>();
let parser: DOMParser;
export const getSvgContent = (url: string, sanitize: boolean) => {
// see if we already have a request for this url
let req = requests.get(url);
/**
* Unsanitized content gets its own key so it's never served to an icon that
* sanitizes.
*/
export const getCacheKey = (url: string, sanitize: boolean) =>
`${sanitize !== false ? 'sanitized' : 'unsanitized'}:${url}`;
if (!req) {
if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
/**
* If the url is a data url of an svg, then try to parse it
* with the DOMParser. This works with content security policies enabled.
*/
if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
if (!parser) {
/**
* Create an instance of the DOM parser. This creates a single
* parser instance for the entire app, which is more efficient.
*/
parser = new DOMParser();
}
const doc = parser.parseFromString(url, 'text/html');
const svg = doc.querySelector('svg');
if (svg) {
ioniconContent.set(url, svg.outerHTML);
}
return Promise.resolve();
} else {
// we don't already have a request
req = fetch(url).then((rsp) => {
if (rsp.ok) {
return rsp.text().then((svgContent) => {
if (svgContent && sanitize !== false) {
svgContent = validateContent(svgContent);
}
ioniconContent.set(url, svgContent || '');
});
}
ioniconContent.set(url, '');
});
// cache for the same requests
requests.set(url, req);
}
/**
* Warns when the whole icon is rejected so it doesn't silently render nothing.
*/
const sanitizeSvg = (url: string, svgContent: string) =>
validateContent(svgContent, () => {
const source = url.length > 100 ? `${url.slice(0, 100)}...` : url;
console.warn(
`[Ionicons Warning]: The SVG from "${source}" was not rendered because it failed sanitization. Only set sanitize="false" for SVG content from a trusted source.`,
);
});
} else {
// set to empty for ssr scenarios and resolve promise
ioniconContent.set(url, '');
return Promise.resolve();
}
/**
* Safely fallback to an empty svg
*/
function safeFallback(cacheKey: string) {
const svg = '';
ioniconContent.set(cacheKey, svg);
return svg;
}
export const getSvgContent = (url: string, sanitize: boolean): Promise<string> => {
const cacheKey = getCacheKey(url, sanitize);
/**
* See if we already have a request for this url
*/
const req = requests.get(cacheKey);
if (req) {
return req;
}
return req;
if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
/**
* If the url is a data url of an svg, then try to parse it
* with the DOMParser. This works with content security policies enabled.
*/
if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
return Promise.resolve(getSvgByUrl(url, sanitize));
}
return fetchSvg(url, sanitize);
}
return Promise.resolve(safeFallback(cacheKey));
};
function getSvgByUrl(url: string, sanitize: boolean): string {
if (!parser) {
/**
* Create an instance of the DOM parser. This creates a single
* parser instance for the entire app, which is more efficient.
*/
parser = new DOMParser();
}
const doc = parser.parseFromString(url, 'text/html');
const svg = doc.querySelector('svg');
if (svg) {
const svgContent = sanitize !== false ? sanitizeSvg(url, svg.outerHTML) : svg.outerHTML;
ioniconContent.set(getCacheKey(url, sanitize), svgContent);
return svgContent;
}
throw new Error(`Could not parse svg from ${url}`);
}
function fetchSvg(url: string, sanitize: boolean): Promise<string> {
const cacheKey = getCacheKey(url, sanitize);
/**
* We don't already have a request
*/
const req = fetch(url)
.then((rsp) => {
/**
* When fetching from a file:// URL, some browsers return
* a 0 status code even when the request succeeds so don't
* rely on rsp.ok as the only signal of success.
*/
return rsp
.text()
.then((svgContent) => {
if (svgContent && sanitize !== false) {
svgContent = sanitizeSvg(url, svgContent);
}
const svg = svgContent || '';
ioniconContent.set(cacheKey, svg);
return svg;
})
.catch(() => safeFallback(cacheKey));
})
.catch(() => safeFallback(cacheKey));
/**
* Cache for the same requests
*/
requests.set(cacheKey, req);
return req;
}
-1
View File
@@ -1,5 +1,4 @@
# this gitignore file is used as a placeholder
# for this directory. The directory itself will
# contain files generated during a build step.
*
!.gitignore
+15
View File
@@ -0,0 +1,15 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
import { AxeBuilder } from '@axe-core/playwright';
test.describe('icon: a11y', () => {
test('should pass accessibility checks', async ({ page }) => {
await page.goto(`/icon/test/a11y/`);
await page.waitForLoadState('networkidle');
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations).toEqual([]);
});
});
+59
View File
@@ -0,0 +1,59 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon - Accessibility</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - Accessibility</h1>
<h2>SVG icon with aria-label</h2>
<ion-icon name="cellular" aria-label="Mobile data"></ion-icon>
<h2>Button with aria-label and SVG icon</h2>
<button aria-label="Mobile data">
<ion-icon name="cellular" aria-hidden="true"></ion-icon>
</button>
<h2>SVG icon with aria-hidden</h2>
<ion-icon name="cellular" aria-hidden="true"></ion-icon>
<hr />
<h2>Font icon with aria-label</h2>
<ion-icon aria-label="Mobile data">
<i class="fa fa-home"></i>
</ion-icon>
<h2>Button with aria-label and font icon</h2>
<button aria-label="Mobile data">
<ion-icon aria-hidden="true">
<i class="fa fa-home"></i>
</ion-icon>
</button>
<h2>Font icon with aria-hidden</h2>
<ion-icon aria-hidden="true">
<i class="fa fa-home"></i>
</ion-icon>
</main>
<style>
ion-icon {
font-size: 32px;
}
</style>
</body>
</html>
@@ -0,0 +1,13 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('icon: basic', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/icon/test/basic/`);
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
await expect(page).toHaveScreenshot(`icon-basic.png`, { fullPage: true });
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

+101
View File
@@ -0,0 +1,101 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon - Basic</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - Basic</h1>
<h2>Default</h2>
<ion-icon name="cellular"></ion-icon>
<ion-icon name="at"></ion-icon>
<ion-icon name="call"></ion-icon>
<ion-icon name="football"></ion-icon>
<ion-icon name="analytics"></ion-icon>
<ion-icon name="grid"></ion-icon>
<ion-icon name="funnel"></ion-icon>
<ion-icon name="watch"></ion-icon>
<ion-icon name="add-circle-outline"></ion-icon>
<h2>Mode from html ios mode attribute</h2>
<ion-icon md="logo-android" ios="logo-apple"></ion-icon>
<ion-icon md="logo-android" ios="logo-apple"></ion-icon>
<h2>Mode set on icon</h2>
<ion-icon mode="ios" md="logo-android" ios="logo-apple"></ion-icon>
<ion-icon mode="md" md="logo-android" ios="logo-apple"></ion-icon>
<h2>Colors</h2>
<ion-icon color="primary" name="cellular"></ion-icon>
<ion-icon color="secondary" name="at"></ion-icon>
<ion-icon color="tertiary" name="call"></ion-icon>
<ion-icon color="success" name="football"></ion-icon>
<ion-icon color="warning" name="analytics"></ion-icon>
<ion-icon color="danger" name="grid"></ion-icon>
<ion-icon color="light" name="funnel"></ion-icon>
<ion-icon color="medium" name="watch"></ion-icon>
<ion-icon color="dark" name="toggle"></ion-icon>
<h2>Stroke width</h2>
<ion-icon name="heart-outline" style="--ionicon-stroke-width: 8px"></ion-icon>
<h2>Font size</h2>
<ion-icon name="book" style="font-size: 50px"></ion-icon>
<ion-icon src="../../assets/bug_report.svg" style="font-size: 50px"></ion-icon>
<h2>Custom SVGs</h2>
<ion-icon src="../../assets/bug_report.svg"></ion-icon>
<ion-icon src="../../assets/chat.svg"></ion-icon>
<ion-icon src="../../assets/commute.svg"></ion-icon>
<ion-icon src="../../assets/copyright.svg"></ion-icon>
<ion-icon src="../../assets/done_all.svg"></ion-icon>
<ion-icon src="../../assets/lock_open.svg"></ion-icon>
<ion-icon src="../../assets/toll.svg"></ion-icon>
<ion-icon src="../../assets/web_asset.svg"></ion-icon>
<ion-icon src="../../assets/work_outline.svg"></ion-icon>
<h2>Custom SVGs: colors</h2>
<ion-icon color="primary" src="../../assets/bug_report.svg"></ion-icon>
<ion-icon color="secondary" src="../../assets/chat.svg"></ion-icon>
<ion-icon color="tertiary" src="../../assets/commute.svg"></ion-icon>
<ion-icon color="success" src="../../assets/copyright.svg"></ion-icon>
<ion-icon color="warning" src="../../assets/done_all.svg"></ion-icon>
<ion-icon color="danger" src="../../assets/lock_open.svg"></ion-icon>
<ion-icon color="light" src="../../assets/toll.svg"></ion-icon>
<ion-icon color="medium" src="../../assets/web_asset.svg"></ion-icon>
<ion-icon color="dark" src="../../assets/work_outline.svg"></ion-icon>
<h2>Custom CSS</h2>
<ion-icon class="custom" name="grid"></ion-icon>
<ion-icon class="custom" name="funnel"></ion-icon>
<ion-icon class="custom" name="watch"></ion-icon>
<ion-icon class="custom" name="logo-react"></ion-icon>
<ion-icon class="custom" name="logo-javascript"></ion-icon>
<ion-icon class="custom" name="logo-angular"></ion-icon>
<ion-icon class="custom" src="../../assets/done_all.svg"></ion-icon>
<ion-icon class="custom" src="../../assets/web_asset.svg"></ion-icon>
<ion-icon class="custom" src="../../assets/work_outline.svg"></ion-icon>
</main>
<style>
ion-icon {
font-size: 32px;
}
.custom {
stroke: red;
fill: blue;
}
</style>
</body>
</html>
@@ -1,15 +1,13 @@
import { expect } from '@playwright/test';
import { test } from '../../../utils/test/playwright';
import { test } from '@utils/test/playwright';
test.describe('icon: csp', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/test/csp');
await page.goto('/icon/test/csp');
});
test('should load svg', async ({ page }) => {
const svg = page.locator('ion-icon#icon-usage svg');
await expect(svg).toBeVisible();
});
});
+52
View File
@@ -0,0 +1,52 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com/*; img-src 'self'; connect-src 'self'; font-src https://fonts.gstatic.com/*'"
/>
<title>Icon - Content Security Policy</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - Content Security Policy</h1>
<h2>Default</h2>
<ion-icon src="/assets/chat.svg"></ion-icon>
<ion-icon name="add"></ion-icon>
<ion-icon
id="icon-usage"
icon="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Watch</title><rect x='136' y='136' width='240' height='240' rx='8' ry='8'/><path d='M384 96h-48V16H176v80h-48a32 32 0 00-32 32v256a32 32 0 0032 32h48v80h160v-80h48a32 32 0 0032-32V128a32 32 0 00-32-32zm8 272a24 24 0 01-24 24H144a24 24 0 01-24-24V144a24 24 0 0124-24h224a24 24 0 0124 24z'/></svg>"
>
</ion-icon>
<ion-icon
class="custom"
icon="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Watch</title><rect x='136' y='136' width='240' height='240' rx='8' ry='8'/><path d='M384 96h-48V16H176v80h-48a32 32 0 00-32 32v256a32 32 0 0032 32h48v80h160v-80h48a32 32 0 0032-32V128a32 32 0 00-32-32zm8 272a24 24 0 01-24 24H144a24 24 0 01-24-24V144a24 24 0 0124-24h224a24 24 0 0124 24z'/></svg>"
>
</ion-icon>
</main>
</body>
<style>
ion-icon {
font-size: 32px;
}
.custom {
stroke: red;
fill: goldenrod;
color: black;
}
</style>
</html>
@@ -1,19 +1,16 @@
import { expect } from '@playwright/test';
import { test } from '../../../utils/test/playwright';
import { test } from '@utils/test/playwright';
test.describe('icon: dynamic type', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/test/dynamic-type');
await page.goto(`/icon/test/dynamic-type/`);
});
test('should scale text on larger font sizes', async ({ page }) => {
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
const icons = page.locator('#icons');
expect(await icons.screenshot()).toMatchSnapshot(`icon-dynamic-type-diff.png`);
const main = page.locator('main');
await expect(main).toHaveScreenshot(`icon-dynamic-type.png`);
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,45 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon - Dynamic Type</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - Dynamic Type</h1>
<h2>Default Icons</h2>
<ion-icon name="star"></ion-icon>
<ion-icon name="star" size="small"></ion-icon>
<ion-icon name="star" size="large"></ion-icon>
<h2>Font Icons</h2>
<ion-icon>
<i class="fa fa-star"></i>
</ion-icon>
<ion-icon size="small">
<i class="fa fa-star"></i>
</ion-icon>
<ion-icon size="large">
<i class="fa fa-star"></i>
</ion-icon>
</main>
<style>
html {
font-size: 28px;
}
</style>
</body>
</html>
+14
View File
@@ -0,0 +1,14 @@
class TestHeader extends HTMLElement {
connectedCallback() {
const header = document.createElement('header');
header.innerHTML = `
<a href="/" class="back-button">
<ion-icon name="arrow-back" aria-hidden="true"></ion-icon>
Back
</a>
`;
this.appendChild(header);
}
}
customElements.define('test-header', TestHeader);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

+186 -63
View File
@@ -1,79 +1,202 @@
import { newSpecPage } from '@stencil/core/testing';
import { newSpecPage } from 'jest-stencil-runner';
import { Icon } from '../icon';
describe('icon', () => {
it('renders', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: '<ion-icon></ion-icon>',
describe('basic rendering', () => {
it('renders', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: '<ion-icon></ion-icon>',
});
expect(root).toEqualHtml(`
<ion-icon class="md" role="img">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
</ion-icon>
`);
});
it('renders rtl with aria-hidden', async () => {
const { root } = await newSpecPage({
components: [Icon],
direction: 'rtl',
html: `<ion-icon name="chevron-forward" aria-hidden="true"></ion-icon>`,
});
expect(root).toEqualHtml(`
<ion-icon class="md flip-rtl icon-rtl" name="chevron-forward" role="img" aria-hidden="true">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
</ion-icon>
`);
});
it('renders custom aria-label', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `<ion-icon name="star" aria-label="custom label"></ion-icon>`,
});
expect(root).toEqualHtml(`
<ion-icon class="md" name="star" role="img" aria-label="custom label">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
</ion-icon>
`);
});
expect(root).toEqualHtml(`
<ion-icon class="md" role="img">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
});
it('renders rtl with aria-hidden', async () => {
const { root } = await newSpecPage({
components: [Icon],
direction: 'rtl',
html: `<ion-icon name="chevron-forward" aria-hidden="true"></ion-icon>`,
});
describe('dynamic rendering', () => {
it('renders custom label after changing source', async () => {
const page = await newSpecPage({
components: [Icon],
html: `<ion-icon name="chevron-forward" aria-label="custom label"></ion-icon>`,
});
expect(root).toEqualHtml(`
<ion-icon class="md flip-rtl icon-rtl" name="chevron-forward" role="img" aria-hidden="true">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
const icon = page.root;
expect(icon).toEqualHtml(`
<ion-icon class="flip-rtl md" name="chevron-forward" role="img" aria-label="custom label">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
</ion-icon>
`);
if (icon) {
icon.name = 'trash';
}
await page.waitForChanges();
expect(icon).toEqualHtml(`
<ion-icon class="md" name="trash" role="img" aria-label="custom label">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
</ion-icon>
`);
});
});
it('renders custom aria-label', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `<ion-icon name="star" aria-label="custom label"></ion-icon>`,
describe('svg rendering scenarios', () => {
it('svgContent=true: renders svg without slot', async () => {
const page = await newSpecPage({
components: [Icon],
html: `<ion-icon aria-hidden="true" part="close-icon" class="close-icon"></ion-icon>`,
});
const icon = page.root as any;
const instance = page.rootInstance as any;
instance.svgContent = '<svg><circle cx="50" cy="50" r="40"/></svg>';
await page.waitForChanges();
const shadowRoot = icon.shadowRoot;
const iconInner = shadowRoot?.querySelector('.icon-inner');
// Should have no slot
const slot = iconInner?.querySelector('slot');
expect(slot).toBeNull();
// SVG should be a direct child of icon-inner,
// not nested in another div
expect(iconInner?.children.length).toBe(1);
const firstChild = iconInner?.children[0];
expect((firstChild as any)?.tagName?.toLowerCase()).toBe('svg');
expect(firstChild?.querySelector('circle')).not.toBeNull();
});
expect(root).toEqualHtml(`
<ion-icon class="md" name="star" role="img" aria-label="custom label">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
it('svgContent=false: renders slot for custom content', async () => {
const page = await newSpecPage({
components: [Icon],
html: `<ion-icon aria-hidden="true" part="close-icon" class="close-icon"></ion-icon>`,
});
const icon = page.root as any;
const shadowRoot = icon.shadowRoot;
const iconInner = shadowRoot?.querySelector('.icon-inner');
const slot = iconInner?.querySelector('slot');
const svg = iconInner?.querySelector('svg');
expect(slot).not.toBeNull();
expect(svg).toBeNull();
});
});
it('renders custom label after changing source', async () => {
const page = await newSpecPage({
components: [Icon],
html: `<ion-icon name="chevron-forward" aria-label="custom label"></ion-icon>`,
describe('slotted content', () => {
it('renders slotted font icon (Font Awesome)', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `
<ion-icon>
<i class="fa fa-home"></i>
</ion-icon>
`,
});
expect(root).toEqualHtml(`
<ion-icon class="md" role="img">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
<i class="fa fa-home"></i>
</ion-icon>
`);
});
const icon = page.root;
expect(icon).toEqualHtml(`
<ion-icon class="flip-rtl md" name="chevron-forward" role="img" aria-label="custom label">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
if (icon) {
icon.name = 'trash';
}
await page.waitForChanges();
it('renders slotted font icon with color', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `
<ion-icon color="primary">
<i class="fa fa-heart"></i>
</ion-icon>
`,
});
expect(root).toEqualHtml(`
<ion-icon class="md ion-color ion-color-primary" color="primary" role="img">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
<i class="fa fa-heart"></i>
</ion-icon>
`);
});
expect(icon).toEqualHtml(`
<ion-icon class="md" name="trash" role="img" aria-label="custom label">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
it('renders slotted font icon with custom style', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `
<ion-icon style="font-size: 48px">
<i class="fa fa-star"></i>
</ion-icon>
`,
});
expect(root).toEqualHtml(`
<ion-icon class="md" role="img" style="font-size: 48px">
<mock:shadow-root>
<div class="icon-inner">
<slot></slot>
</div>
</mock:shadow-root>
<i class="fa fa-star"></i>
</ion-icon>
`);
});
});
});
+66
View File
@@ -0,0 +1,66 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon Tests</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="./icon/test/styles.css" />
<script src="./icon/test/header.js"></script>
</head>
<body>
<main>
<h1>Icon Tests</h1>
<p>Select a test category to view the icon component tests.</p>
<div class="grid">
<a href="/icon/test/a11y/" class="card">
<h3>Accessibility</h3>
<p>ARIA labels and accessible icon patterns</p>
</a>
<a href="/icon/test/basic/" class="card">
<h3>Basic</h3>
<p>Default SVG icons, modes, colors, sizes, and custom SVGs</p>
</a>
<a href="/icon/test/cheatsheet/" class="card">
<h3>Cheatsheet</h3>
<p>Visual reference of all available ionicons</p>
</a>
<a href="/icon/test/csp/" class="card">
<h3>Content Security Policy</h3>
<p>SVG content loading with Content Security Policy</p>
</a>
<a href="/icon/test/dynamic-type/" class="card">
<h3>Dynamic Type</h3>
<p>Font size scaling and dynamic text sizing behavior</p>
</a>
<a href="/icon/test/rtl/" class="card">
<h3>RTL</h3>
<p>Right-to-left text direction and icon flipping behavior</p>
</a>
<a href="/icon/test/sanitization/" class="card">
<h3>Sanitization</h3>
<p>SVG content sanitization and security</p>
</a>
<a href="/icon/test/size/" class="card">
<h3>Size</h3>
<p>Size prop with small and large variants for native and slotted icons</p>
</a>
<a href="/icon/test/slotted/" class="card">
<h3>Slotted Content</h3>
<p>Font Awesome, Material, Phosphor, Bootstrap, and custom SVGs</p>
</a>
</div>
</main>
</body>
</html>
@@ -1,18 +1,9 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('icon: basic', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/`);
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(`icon-diff.png`);
});
test.describe('icon: rtl', () => {
test('some icons should flip when rtl', async ({ page }) => {
await page.goto(`/`);
await page.goto(`/icon/test/rtl/`);
const autoflip = page.locator('.auto-flip-chevrons [name=chevron-forward] .icon-inner');
const unflip = page.locator('.un-flip-chevrons [name=chevron-forward] .icon-inner');
@@ -29,12 +20,11 @@ test.describe('icon: basic', () => {
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
const rtlTests = page.locator('#rtl-tests');
await expect(rtlTests).toHaveScreenshot(`icon-rtl-diff.png`);
await expect(page).toHaveScreenshot(`icon-rtl.png`);
});
test('arrows should flip if dir changes on the element', async ({ page }) => {
await page.goto(`/`);
await page.goto(`/icon/test/rtl/`);
const autoflip = page.locator('.auto-flip-chevrons [name=chevron-forward] .icon-inner');
const unflip = page.locator('.un-flip-chevrons [name=chevron-forward] .icon-inner');
@@ -51,7 +41,7 @@ test.describe('icon: basic', () => {
});
test('icon should reassess flipping when name changes', async ({ page }) => {
await page.goto(`/`);
await page.goto(`/icon/test/rtl/`);
await page.evaluate(() => {
document.dir = 'rtl';
@@ -67,5 +57,4 @@ test.describe('icon: basic', () => {
await expect(iconLoc).toHaveAttribute('name', 'brush');
await expect(iconLoc).not.toHaveClass(/flip-rtl/);
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

+72
View File
@@ -0,0 +1,72 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon - RTL</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - RTL</h1>
<h2>Default: Non-arrows</h2>
<ion-icon name="cut"></ion-icon>
<ion-icon name="call"></ion-icon>
<ion-icon name="checkbox"></ion-icon>
<ion-icon name="brush"></ion-icon>
<h2>Flip: Non-arrows</h2>
<ion-icon name="cut" flip-rtl></ion-icon>
<ion-icon name="call" flip-rtl></ion-icon>
<ion-icon name="checkbox" flip-rtl></ion-icon>
<ion-icon name="brush" flip-rtl></ion-icon>
<h2>Auto Flip: arrows</h2>
<ion-icon name="arrow-up"></ion-icon>
<ion-icon name="arrow-forward"></ion-icon>
<ion-icon name="arrow-down"></ion-icon>
<ion-icon name="arrow-back"></ion-icon>
<h2>Un-flip: arrows</h2>
<ion-icon name="arrow-up" flip-rtl="false"></ion-icon>
<ion-icon name="arrow-forward" flip-rtl="false"></ion-icon>
<ion-icon name="arrow-down" flip-rtl="false"></ion-icon>
<ion-icon name="arrow-back" flip-rtl="false"></ion-icon>
<h2>Auto Flip: chevrons</h2>
<div class="auto-flip-chevrons">
<ion-icon name="chevron-up"></ion-icon>
<ion-icon name="chevron-forward"></ion-icon>
<ion-icon name="chevron-down"></ion-icon>
<ion-icon name="chevron-back"></ion-icon>
</div>
<h2>Un-flip: chevrons</h2>
<div class="un-flip-chevrons">
<ion-icon name="chevron-up" flip-rtl="false"></ion-icon>
<ion-icon name="chevron-forward" flip-rtl="false"></ion-icon>
<ion-icon name="chevron-down" flip-rtl="false"></ion-icon>
<ion-icon name="chevron-back" flip-rtl="false"></ion-icon>
</div>
<h2>Auto Flip, RTL on components</h2>
<ion-icon name="arrow-up" dir="rtl" flip-rtl></ion-icon>
<ion-icon name="arrow-forward" dir="rtl" flip-rtl></ion-icon>
<ion-icon name="arrow-down" dir="rtl" flip-rtl></ion-icon>
<ion-icon name="arrow-back" dir="rtl" flip-rtl></ion-icon>
</main>
<style>
ion-icon {
font-size: 32px;
}
</style>
</body>
</html>
@@ -0,0 +1,284 @@
import { expect } from '@playwright/test';
import type { E2EPage } from '@utils/test/playwright';
import { test } from '@utils/test/playwright';
/**
* An SVG whose handler pushes `label` to `window.xssFired` if it ever runs.
*/
const imageOnErrorSvg = (label: string) =>
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><image href="x" onerror="window.xssFired.push('${label}')"/></svg>`;
const utf8DataUrl = (svg: string) => `data:image/svg+xml;utf8,${svg}`;
/**
* Sets `sanitize` before `src` so the icon loads with the intended setting.
*/
const addIcon = (page: E2EPage, id: string, src: string, sanitize?: boolean) =>
page.evaluate(
([id, src, sanitize]) => {
const icon = document.createElement('ion-icon') as any;
icon.id = id;
if (sanitize !== undefined) {
icon.sanitize = sanitize;
}
icon.src = src;
document.body.appendChild(icon);
},
[id, src, sanitize] as const,
);
/**
* Waits for the unsanitized control icon's handler to fire. Any `data:` URL
* payload added before it has had at least as long to fire.
*/
const waitForControl = (page: E2EPage) => page.waitForFunction(() => (window as any).xssFired.includes('control'));
const getFired = (page: E2EPage) => page.evaluate(() => (window as any).xssFired as string[]);
test.describe('icon: sanitization', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/icon/test/sanitization/`);
await page.waitForLoadState('networkidle');
const main = page.locator('main');
await expect(main).toHaveScreenshot(`icon-sanitization.png`);
});
});
test.describe('icon: sanitization: unsafe content', () => {
test.beforeEach(async ({ page }) => {
await page.setContent(`<script>window.xssFired = [];</script>`);
});
test('should not run handlers from a utf8 svg data url', async ({ page }) => {
await addIcon(page, 'attack', utf8DataUrl(imageOnErrorSvg('attack')));
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
await waitForControl(page);
expect(await getFired(page)).not.toContain('attack');
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
});
test('should render a clean utf8 svg data url', async ({ page }) => {
const clean = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>`;
await addIcon(page, 'clean', utf8DataUrl(clean));
await expect(page.locator('#clean .icon-inner svg path')).toHaveCount(1);
});
test('should warn when an svg is rejected', async ({ page }) => {
const warnings: string[] = [];
page.on('console', (msg) => {
if (msg.type() === 'warning') {
warnings.push(msg.text());
}
});
await addIcon(page, 'attack', utf8DataUrl(imageOnErrorSvg('attack')));
await expect.poll(() => warnings.some((warning) => warning.includes('[Ionicons Warning]'))).toBe(true);
});
test('should not warn about sanitizing when the response is not an svg', async ({ page }) => {
const warnings: string[] = [];
page.on('console', (msg) => {
if (msg.type() === 'warning') {
warnings.push(msg.text());
}
});
await page.route('**/missing.svg', (route) =>
route.fulfill({ status: 404, contentType: 'text/html', body: '<html><body>Not found</body></html>' }),
);
await page.route('**/rejected.svg', (route) =>
route.fulfill({ contentType: 'image/svg+xml', body: imageOnErrorSvg('attack') }),
);
const missingLoaded = page.waitForResponse('**/missing.svg');
await addIcon(page, 'missing', '/missing.svg');
await missingLoaded;
// This takes the same fetch and sanitize steps, so once it warns the 404 has been handled
await addIcon(page, 'rejected', '/rejected.svg');
await expect.poll(() => warnings.some((warning) => warning.includes('rejected.svg'))).toBe(true);
expect(warnings.filter((warning) => warning.includes('missing.svg'))).toHaveLength(0);
});
test('should not run handlers from a fetched svg while sanitizing it', async ({ page }) => {
await page.route('**/xss/*.svg', (route) => {
const label = route.request().url().includes('control') ? 'control' : 'attack';
route.fulfill({
contentType: 'image/svg+xml',
body: `<img src="x" onerror="window.xssFired.push('${label}')">${imageOnErrorSvg(label)}`,
});
});
// Fetches resolve independently, so let the attack load before the control starts
const attackLoaded = page.waitForResponse('**/xss/attack.svg');
await addIcon(page, 'attack', '/xss/attack.svg');
await attackLoaded;
await addIcon(page, 'control', '/xss/control.svg', false);
await waitForControl(page);
expect(await getFired(page)).not.toContain('attack');
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
});
test('should reject a fetched svg with more than one root svg', async ({ page }) => {
await page.route('**/xss/*.svg', (route) => {
const label = route.request().url().includes('control') ? 'control' : 'attack';
route.fulfill({
contentType: 'image/svg+xml',
body: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>${imageOnErrorSvg(label)}`,
});
});
const attackLoaded = page.waitForResponse('**/xss/attack.svg');
await addIcon(page, 'attack', '/xss/attack.svg');
await attackLoaded;
await addIcon(page, 'control', '/xss/control.svg', false);
await waitForControl(page);
expect(await getFired(page)).not.toContain('attack');
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
});
const htmlInSvgPayloads = [
{
name: 'noscript',
inner: `<desc><noscript><p title="</noscript><img src=x onerror=top.xssFired.push('attack')>"></p></noscript></desc>`,
},
{
name: 'template',
inner: `<desc><template><img src="x" onerror="top.xssFired.push('attack')"></template></desc>`,
},
];
htmlInSvgPayloads.forEach(({ name, inner }) => {
test(`should reject an svg containing an html ${name} element`, async ({ page }) => {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">${inner}<path d="M0 0h24v24H0z"/></svg>`;
await addIcon(page, 'attack', utf8DataUrl(svg));
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
await waitForControl(page);
expect(await getFired(page)).not.toContain('attack');
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
});
});
const foreignObjectPayloads = [
{
name: 'iframe srcdoc',
inner: `<iframe xmlns="http://www.w3.org/1999/xhtml" srcdoc="&lt;script&gt;top.xssFired.push('attack')&lt;/script&gt;"></iframe>`,
},
{
name: 'iframe javascript: src',
inner: `<iframe xmlns="http://www.w3.org/1999/xhtml" src="javascript:top.xssFired.push('attack')"></iframe>`,
},
];
foreignObjectPayloads.forEach(({ name, inner }) => {
test(`should remove a foreignObject containing an ${name}`, async ({ page }) => {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><foreignObject width="24" height="24">${inner}</foreignObject><path d="M0 0h24v24H0z"/></svg>`;
await addIcon(page, 'attack', utf8DataUrl(svg));
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
await waitForControl(page);
expect(await getFired(page)).not.toContain('attack');
await expect(page.locator('#attack .icon-inner svg path')).toHaveCount(1);
await expect(page.locator('#attack .icon-inner svg > :not(path)')).toHaveCount(0);
});
});
test('should render an illustrator export that uses a switch with a foreignObject', async ({ page }) => {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><switch><foreignObject requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" x="0" y="0" width="1" height="1"><i:pgfRef xlink:href="#adobe_illustrator_pgf"></i:pgfRef></foreignObject><g i:extraneous="self"><path d="M0 0h24v24H0z"/></g></switch></svg>`;
await addIcon(page, 'illustrator', utf8DataUrl(svg));
await expect(page.locator('#illustrator .icon-inner svg path')).toHaveCount(1);
});
const javascriptUrlPayloads = [
{ name: 'an anchor href', inner: `<a href="javascript:top.xssFired.push('attack')"><path d="M0 0h24v24H0z"/></a>` },
{
name: 'an obfuscated xlink:href',
inner: `<a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href=" JaVa&#x09;ScRiPt:top.xssFired.push('attack')"><path d="M0 0h24v24H0z"/></a>`,
},
{
name: 'an animate element',
inner: `<a><animate attributeName="href" values="https://ionic.io;javascript:top.xssFired.push('attack')"/><path d="M0 0h24v24H0z"/></a>`,
},
{
name: 'a set element',
inner: `<a><set attributeName="href" to="javascript:top.xssFired.push('attack')"/><path d="M0 0h24v24H0z"/></a>`,
},
];
javascriptUrlPayloads.forEach(({ name, inner }) => {
test(`should reject an svg with a javascript: url in ${name}`, async ({ page }) => {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">${inner}</svg>`;
await addIcon(page, 'attack', utf8DataUrl(svg));
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
await waitForControl(page);
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
});
});
test('should not reuse unsanitized content cached for the same data url', async ({ page }) => {
const shared = utf8DataUrl(imageOnErrorSvg('shared'));
await addIcon(page, 'unsanitized', shared, false);
await page.waitForFunction(() => (window as any).xssFired.includes('shared'));
await addIcon(page, 'sanitized', shared);
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
await waitForControl(page);
await expect(page.locator('#sanitized .icon-inner svg')).toHaveCount(0);
expect((await getFired(page)).filter((label) => label === 'shared')).toHaveLength(1);
});
test('should not reuse sanitized content cached for the same data url', async ({ page }) => {
const shared = utf8DataUrl(imageOnErrorSvg('shared'));
await addIcon(page, 'sanitized', shared);
await addIcon(page, 'unsanitized', shared, false);
await expect(page.locator('#unsanitized .icon-inner svg')).toHaveCount(1);
});
test('should not let a src forge the unsanitized cache key', async ({ page }) => {
const shared = utf8DataUrl(imageOnErrorSvg('shared'));
await addIcon(page, 'unsanitized', shared, false);
await page.waitForFunction(() => (window as any).xssFired.includes('shared'));
await addIcon(page, 'sanitized', `unsanitized:${shared}`);
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
await waitForControl(page);
await expect(page.locator('#sanitized .icon-inner svg')).toHaveCount(0);
expect((await getFired(page)).filter((label) => label === 'shared')).toHaveLength(1);
});
test('should not reuse an unsanitized in-flight fetch for the same url', async ({ page }) => {
await page.route('**/xss/*.svg', (route) => {
const label = route.request().url().includes('control') ? 'control' : 'shared';
// Sanitizing drops the <img> sibling and keeps the clean <svg>
route.fulfill({
contentType: 'image/svg+xml',
body: `<img src="x" onerror="window.xssFired.push('${label}')"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>`,
});
});
await addIcon(page, 'unsanitized', '/xss/shared.svg', false);
await addIcon(page, 'sanitized', '/xss/shared.svg');
await addIcon(page, 'control', '/xss/control.svg', false);
await waitForControl(page);
await page.waitForFunction(() => (window as any).xssFired.includes('shared'));
await expect(page.locator('#sanitized .icon-inner svg path')).toHaveCount(1);
await expect(page.locator('#sanitized .icon-inner img')).toHaveCount(0);
expect((await getFired(page)).filter((label) => label === 'shared')).toHaveLength(1);
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1,37 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon - Sanitization</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - Sanitization</h1>
<h2>Sanitized (shouldn't show)</h2>
<ion-icon src="/icon/assets/sanitize.svg"></ion-icon>
<h2>Not Sanitized (should show)</h2>
<ion-icon sanitize="false" src="/icon/assets/no-sanitize.svg"></ion-icon>
<h2>Base64 URL</h2>
<ion-icon
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDI0djI0SDBWMHoiLz48cGF0aCBkPSJNMjAgMkg0Yy0xLjEgMC0yIC45LTIgMnYxOGw0LTRoMTRjMS4xIDAgMi0uOSAyLTJWNGMwLTEuMS0uOS0yLTItMnptMCAxNEg2bC0yIDJWNGgxNnYxMnoiLz48L3N2Zz4="
></ion-icon>
</main>
<style>
ion-icon {
font-size: 32px;
}
</style>
</body>
</html>
+40
View File
@@ -0,0 +1,40 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('icon: size', () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/icon/test/size/`);
});
test('should scale the icon based on the size property', async ({ page }) => {
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
const main = page.locator('main');
await expect(main).toHaveScreenshot(`icon-size.png`);
});
test('size prop should apply correct font-size to SVG icons', async ({ page }) => {
// Wait for all SVGs to be lazily loaded
await page.waitForLoadState('networkidle');
const icons = page.locator('ion-icon[name="heart"]');
// Default size is 16px, small is 18px, large is 32px
expect(await icons.nth(0).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('16px');
expect(await icons.nth(1).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('18px');
expect(await icons.nth(2).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('32px');
});
test('size prop should apply correct font-size to font icons', async ({ page }) => {
// Wait for document fonts to be ready
await page.evaluate(() => document.fonts.ready);
const icons = page.locator('ion-icon:not([name])');
// Default size is 16px, small is 18px, large is 32px
expect(await icons.nth(0).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('16px');
expect(await icons.nth(1).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('18px');
expect(await icons.nth(2).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('32px');
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+39
View File
@@ -0,0 +1,39 @@
<!doctype html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Icon - Size</title>
<script type="module" src="/build/ionicons.esm.js"></script>
<script nomodule src="/build/ionicons.js"></script>
<link rel="stylesheet" href="../styles.css" />
<script src="../header.js"></script>
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
</head>
<body>
<test-header></test-header>
<main>
<h1>Icon - Size</h1>
<h2>Default Icons</h2>
<ion-icon name="heart"></ion-icon>
<ion-icon name="heart" size="small"></ion-icon>
<ion-icon name="heart" size="large"></ion-icon>
<h2>Font Icons</h2>
<ion-icon>
<i class="fa fa-heart"></i>
</ion-icon>
<ion-icon size="small">
<i class="fa fa-heart"></i>
</ion-icon>
<ion-icon size="large">
<i class="fa fa-heart"></i>
</ion-icon>
</main>
</body>
</html>
@@ -0,0 +1,13 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('icon: slotted', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/icon/test/slotted/`);
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
await expect(page).toHaveScreenshot(`icon-slotted.png`, { fullPage: true });
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Some files were not shown because too many files have changed in this diff Show More