Skip to content

Commit 015b1ce

Browse files
docs(theming): update icon playgrounds to use addIcons usage (#3758)
1 parent db9edc5 commit 015b1ce

File tree

26 files changed

+351
-2
lines changed

26 files changed

+351
-2
lines changed

static/usage/v7/theming/automatic-dark-mode/angular/example_component_ts.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
```ts
22
import { Component, OnInit } from '@angular/core';
33

4+
import { addIcons } from 'ionicons';
5+
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
6+
47
@Component({
58
selector: 'app-example',
69
templateUrl: 'example.component.html',
710
})
811
export class ExampleComponent implements OnInit {
12+
constructor() {
13+
/**
14+
* Any icons you want to use in your application
15+
* can be registered in app.component.ts and then
16+
* referenced by name anywhere in your application.
17+
*/
18+
addIcons({ personCircle, personCircleOutline, sunny, sunnyOutline });
19+
}
20+
921
ngOnInit() {
1022
// Use matchMedia to check the user preference
1123
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');

static/usage/v7/theming/automatic-dark-mode/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Playground from '@site/src/components/global/Playground';
22

3-
import javascript_index_html from './javascript.md';
3+
import javascript_index_html from './javascript/index_html.md';
4+
import javascript_index_ts from './javascript/index_ts.md';
45

56
import react_main_tsx from './react/main_tsx.md';
67
import react_main_css from './react/main_css.md';
@@ -19,8 +20,12 @@ import variables_css from './theme/variables_css.md';
1920
javascript: {
2021
files: {
2122
'index.html': javascript_index_html,
23+
'index.ts': javascript_index_ts,
2224
'theme/variables.css': variables_css,
2325
},
26+
dependencies: {
27+
ionicons: '7.4.0',
28+
},
2429
},
2530
react: {
2631
files: {
@@ -42,6 +47,9 @@ import variables_css from './theme/variables_css.md';
4247
'src/global.css': angular_global_css,
4348
'src/theme/variables.css': variables_css,
4449
},
50+
dependencies: {
51+
ionicons: '7.4.0',
52+
},
4553
},
4654
}}
4755
src="usage/v7/theming/automatic-dark-mode/demo.html"
File renamed without changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```ts
2+
import { defineCustomElements } from '@ionic/core/loader';
3+
4+
import { addIcons } from 'ionicons';
5+
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
6+
7+
/* Core CSS required for Ionic components to work properly */
8+
import '@ionic/core/css/core.css';
9+
10+
/* Basic CSS for apps built with Ionic */
11+
import '@ionic/core/css/normalize.css';
12+
import '@ionic/core/css/structure.css';
13+
import '@ionic/core/css/typography.css';
14+
15+
/* Optional CSS utils that can be commented out */
16+
import '@ionic/core/css/padding.css';
17+
import '@ionic/core/css/float-elements.css';
18+
import '@ionic/core/css/text-alignment.css';
19+
import '@ionic/core/css/text-transformation.css';
20+
import '@ionic/core/css/flex-utils.css';
21+
import '@ionic/core/css/display.css';
22+
23+
/* Theme variables */
24+
import './theme/variables.css';
25+
26+
/**
27+
* On Ionicons 7.2+ these icons
28+
* get mapped to a kebab-case key.
29+
* Alternatively, developers can do:
30+
* addIcons({ 'person-circle': personCircle, 'person-circle-outline': personCircleOutline,
31+
* 'sunny': sunny, 'sunny-outline': sunnyOutline });
32+
*/
33+
addIcons({ personCircle, personCircleOutline, sunny, sunnyOutline });
34+
35+
defineCustomElements();
36+
```

static/usage/v7/theming/manual-dark-mode/angular/example_component_ts.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
```ts
22
import { Component, OnInit } from '@angular/core';
33

4+
import { addIcons } from 'ionicons';
5+
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
6+
47
@Component({
58
selector: 'app-example',
69
templateUrl: 'example.component.html',
710
})
811
export class ExampleComponent implements OnInit {
912
themeToggle = false;
1013

14+
constructor() {
15+
/**
16+
* Any icons you want to use in your application
17+
* can be registered in app.component.ts and then
18+
* referenced by name anywhere in your application.
19+
*/
20+
addIcons({ personCircle, personCircleOutline, sunny, sunnyOutline });
21+
}
22+
1123
ngOnInit() {
1224
// Use matchMedia to check the user preference
1325
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');

static/usage/v7/theming/manual-dark-mode/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Playground from '@site/src/components/global/Playground';
22

3-
import javascript_index_html from './javascript.md';
3+
import javascript_index_html from './javascript/index_html.md';
4+
import javascript_index_ts from './javascript/index_ts.md';
45

56
import react_main_tsx from './react/main_tsx.md';
67
import react_main_css from './react/main_css.md';
@@ -19,8 +20,12 @@ import variables_css from './theme/variables_css.md';
1920
javascript: {
2021
files: {
2122
'index.html': javascript_index_html,
23+
'index.ts': javascript_index_ts,
2224
'theme/variables.css': variables_css,
2325
},
26+
dependencies: {
27+
ionicons: '7.4.0',
28+
},
2429
},
2530
react: {
2631
files: {
@@ -42,6 +47,9 @@ import variables_css from './theme/variables_css.md';
4247
'src/global.css': angular_global_css,
4348
'src/theme/variables.css': variables_css,
4449
},
50+
dependencies: {
51+
ionicons: '7.4.0',
52+
},
4553
},
4654
}}
4755
src="usage/v7/theming/manual-dark-mode/demo.html"
File renamed without changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```ts
2+
import { defineCustomElements } from '@ionic/core/loader';
3+
4+
import { addIcons } from 'ionicons';
5+
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
6+
7+
/* Core CSS required for Ionic components to work properly */
8+
import '@ionic/core/css/core.css';
9+
10+
/* Basic CSS for apps built with Ionic */
11+
import '@ionic/core/css/normalize.css';
12+
import '@ionic/core/css/structure.css';
13+
import '@ionic/core/css/typography.css';
14+
15+
/* Optional CSS utils that can be commented out */
16+
import '@ionic/core/css/padding.css';
17+
import '@ionic/core/css/float-elements.css';
18+
import '@ionic/core/css/text-alignment.css';
19+
import '@ionic/core/css/text-transformation.css';
20+
import '@ionic/core/css/flex-utils.css';
21+
import '@ionic/core/css/display.css';
22+
23+
/* Theme variables */
24+
import './theme/variables.css';
25+
26+
/**
27+
* On Ionicons 7.2+ these icons
28+
* get mapped to a kebab-case key.
29+
* Alternatively, developers can do:
30+
* addIcons({ 'person-circle': personCircle, 'person-circle-outline': personCircleOutline,
31+
* 'sunny': sunny, 'sunny-outline': sunnyOutline });
32+
*/
33+
addIcons({ personCircle, personCircleOutline, sunny, sunnyOutline });
34+
35+
defineCustomElements();
36+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```ts
2+
import { Component } from '@angular/core';
3+
4+
import { addIcons } from 'ionicons';
5+
import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons';
6+
7+
@Component({
8+
selector: 'app-example',
9+
templateUrl: 'example.component.html',
10+
styleUrls: ['example.component.css'],
11+
})
12+
export class ExampleComponent {
13+
constructor() {
14+
/**
15+
* Any icons you want to use in your application
16+
* can be registered in app.component.ts and then
17+
* referenced by name anywhere in your application.
18+
*/
19+
addIcons({ personCircle, personCircleOutline, sunny, sunnyOutline });
20+
}
21+
}
22+
```

static/usage/v8/theming/always-dark-mode/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import react_app_tsx from './react/app_tsx.md';
77
import react_main_tsx from './react/main_tsx.md';
88

99
import angular_example_component_html from './angular/example_component_html.md';
10+
import angular_example_component_ts from './angular/example_component_ts.md';
1011
import angular_styles_css from './angular/styles_css.md';
1112

1213
import vue_example from './vue/example_vue.md';
@@ -23,6 +24,9 @@ import variables_css from './theme/variables_css.md';
2324
'index.ts': javascript_index_ts,
2425
'theme/variables.css': variables_css,
2526
},
27+
dependencies: {
28+
ionicons: '7.4.0',
29+
},
2630
},
2731
react: {
2832
files: {
@@ -41,9 +45,13 @@ import variables_css from './theme/variables_css.md';
4145
angular: {
4246
files: {
4347
'src/app/example.component.html': angular_example_component_html,
48+
'src/app/example.component.ts': angular_example_component_ts,
4449
'src/styles.css': angular_styles_css,
4550
'src/theme/variables.css': variables_css,
4651
},
52+
dependencies: {
53+
ionicons: '7.4.0',
54+
},
4755
},
4856
}}
4957
src="usage/v8/theming/always-dark-mode/demo.html"

0 commit comments

Comments
 (0)