Skip to content

Commit 90a1aca

Browse files
committed
docs(react): remove periods from comments
1 parent 52f3519 commit 90a1aca

File tree

12 files changed

+95
-95
lines changed

12 files changed

+95
-95
lines changed

docs/react/your-first-app.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ Next, import `@ionic/pwa-elements` by editing `src/main.tsx`.
104104
import React from 'react';
105105
import { createRoot } from 'react-dom/client';
106106
import App from './App';
107-
// CHANGE: Add the following import.
107+
// CHANGE: Add the following import
108108
import { defineCustomElements } from '@ionic/pwa-elements/loader';
109109

110-
// CHANGE: Call the element loader before the render call.
110+
// CHANGE: Call the element loader before the render call
111111
defineCustomElements(window);
112112

113113
const container = document.getElementById('root');
@@ -176,9 +176,9 @@ export default Tab2;
176176
We put the visual aspects of our app into `<IonContent>`. In this case, it’s where we’ll add a button that opens the device’s camera as well as displays the image captured by the camera. Start by adding a [floating action button](../api/fab.md) (FAB) to the bottom of the page and set the camera image as the icon.
177177

178178
```tsx
179-
// CHANGE: Add the following import.
179+
// CHANGE: Add the following import
180180
import { camera, trash, close } from 'ionicons/icons';
181-
// CHANGE: Update the following import.
181+
// CHANGE: Update the following import
182182
import {
183183
IonContent,
184184
IonHeader,
@@ -194,7 +194,7 @@ import {
194194
IonImg,
195195
IonActionSheet,
196196
} from '@ionic/react';
197-
// CHANGE: Remove or comment out `ExploreContainer`.
197+
// CHANGE: Remove or comment out `ExploreContainer`
198198
// import ExploreContainer from '../components/ExploreContainer';
199199
import './Tab2.css';
200200

@@ -212,14 +212,14 @@ const Tab2: React.FC = () => {
212212
<IonTitle size="large">Photo Gallery</IonTitle>
213213
</IonToolbar>
214214
</IonHeader>
215-
{/* CHANGE: Add the floating action button. */}
215+
{/* CHANGE: Add the floating action button */}
216216
<IonFab vertical="bottom" horizontal="center" slot="fixed">
217217
<IonFabButton>
218218
<IonIcon icon={camera}></IonIcon>
219219
</IonFabButton>
220220
</IonFab>
221221
</IonContent>
222-
{/* CHANGE: Remove or comment out `ExploreContainer`. */}
222+
{/* CHANGE: Remove or comment out `ExploreContainer` */}
223223
{/* <ExploreContainer name="Tab 2 page" /> */}
224224
</IonPage>
225225
);
@@ -243,7 +243,7 @@ import {
243243
setupIonicReact,
244244
} from '@ionic/react';
245245
import { IonReactRouter } from '@ionic/react-router';
246-
// CHANGE: Update the following import.
246+
// CHANGE: Update the following import
247247
import { images, square, triangle } from 'ionicons/icons';
248248
import Tab1 from './pages/Tab1';
249249
import Tab2 from './pages/Tab2';
@@ -275,9 +275,9 @@ const App: React.FC = () => (
275275
<IonLabel>Tab 1</IonLabel>
276276
</IonTabButton>
277277
<IonTabButton tab="tab2" href="/tab2">
278-
{/* CHANGE: Update icon. */}
278+
{/* CHANGE: Update icon */}
279279
<IonIcon aria-hidden="true" icon={images} />
280-
{/* CHANGE: Update label. */}
280+
{/* CHANGE: Update label */}
281281
<IonLabel>Photos</IonLabel>
282282
</IonTabButton>
283283
<IonTabButton tab="tab3" href="/tab3">

docs/react/your-first-app/2-taking-photos.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ import {
6666
IonImg,
6767
IonActionSheet,
6868
} from '@ionic/react';
69-
// CHANGE: Add `usePhotoGallery` import.
69+
// CHANGE: Add `usePhotoGallery` import
7070
import { usePhotoGallery } from '../hooks/usePhotoGallery';
7171
import './Tab2.css';
7272

7373
const Tab2: React.FC = () => {
74-
// CHANGE: Destructure `addNewToGallery()` from `usePhotoGallery()`.
74+
// CHANGE: Destructure `addNewToGallery()` from `usePhotoGallery()`
7575
const { addNewToGallery } = usePhotoGallery();
7676

7777
return (
@@ -89,7 +89,7 @@ const Tab2: React.FC = () => {
8989
</IonHeader>
9090

9191
<IonFab vertical="bottom" horizontal="center" slot="fixed">
92-
{/* CHANGE: Add a click event listener to the floating action button. */}
92+
{/* CHANGE: Add a click event listener to the floating action button */}
9393
<IonFabButton onClick={() => addNewToGallery()}>
9494
<IonIcon icon={camera}></IonIcon>
9595
</IonFabButton>
@@ -121,7 +121,7 @@ export function usePhotoGallery {
121121
// Same old code from before.
122122
}
123123

124-
// CHANGE: Add the `UserPhoto` interface.
124+
// CHANGE: Add the `UserPhoto` interface
125125
export interface UserPhoto {
126126
filepath: string;
127127
webviewPath?: string;
@@ -132,7 +132,7 @@ Above the `addNewToGallery()` method, define an array of `UserPhoto`, which will
132132

133133
```ts
134134
export function usePhotoGallery {
135-
// CHANGE: Add the `photos` array.
135+
// CHANGE: Add the `photos` array
136136
const [photos, setPhotos] = useState<UserPhoto[]>([]);
137137

138138
// Same old code from before.
@@ -153,9 +153,9 @@ export function usePhotoGallery() {
153153
quality: 100,
154154
});
155155

156-
// CHANGE: Create the `fileName` with current timestamp.
156+
// CHANGE: Create the `fileName` with current timestamp
157157
const fileName = Date.now() + '.jpeg';
158-
// CHANGE: Create `savedImageFile` matching `UserPhoto` interface.
158+
// CHANGE: Create `savedImageFile` matching `UserPhoto` interface
159159
const savedImageFile = [
160160
{
161161
filepath: fileName,
@@ -164,13 +164,13 @@ export function usePhotoGallery() {
164164
...photos,
165165
];
166166

167-
// CHANGE: Update the `photos` array with the new photo.
167+
// CHANGE: Update the `photos` array with the new photo
168168
setPhotos(savedImageFile);
169169
};
170170

171171
return {
172172
addNewToGallery,
173-
// CHANGE: Update return statement to include `photos` array.
173+
// CHANGE: Update return statement to include `photos` array
174174
photos,
175175
};
176176
}
@@ -223,7 +223,7 @@ Next, switch to `Tab2.tsx` to display the images. We'll add a [Grid component](.
223223

224224
```tsx
225225
const Tab2: React.FC = () => {
226-
// CHANGE: Add `photos` array to destructure from `usePhotoGallery()`.
226+
// CHANGE: Add `photos` array to destructure from `usePhotoGallery()`
227227
const { photos, addNewToGallery } = usePhotoGallery();
228228

229229
return (
@@ -240,10 +240,10 @@ const Tab2: React.FC = () => {
240240
</IonToolbar>
241241
</IonHeader>
242242

243-
{/* CHANGE: Add a grid component to display the photos. */}
243+
{/* CHANGE: Add a grid component to display the photos */}
244244
<IonGrid>
245245
<IonRow>
246-
{/* CHANGE: Create a new column and image component for each photo. */}
246+
{/* CHANGE: Create a new column and image component for each photo */}
247247
{photos.map((photo) => (
248248
<IonCol size="6" key={photo.filepath}>
249249
<IonImg src={photo.webviewPath} />

docs/react/your-first-app/3-saving-photos.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { Preferences } from '@capacitor/preferences';
2828
export function usePhotoGallery() {
2929
// Same old code from before.
3030

31-
// CHANGE: Add the `savePicture()` method.
31+
// CHANGE: Add the `savePicture()` method
3232
const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> => {
3333
return {
3434
filepath: 'soon...',
@@ -68,16 +68,16 @@ export function usePhotoGallery() {
6868
});
6969

7070
const fileName = Date.now() + '.jpeg';
71-
// CHANGE: Add `savedImageFile`.
71+
// CHANGE: Add `savedImageFile`
7272
// Save the picture and add it to photo collection
7373
const savedImageFile = await savePicture(capturedPhoto, fileName);
7474

75-
// CHANGE: Update state with new photo.
75+
// CHANGE: Update state with new photo
7676
const newPhotos = [savedImageFile, ...photos];
7777
setPhotos(newPhotos);
7878
};
7979

80-
// CHANGE: Add `savePicture()` method.
80+
// CHANGE: Add `savePicture()` method
8181
const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> => {
8282
return {
8383
filepath: 'soon...',
@@ -112,7 +112,7 @@ import { Preferences } from '@capacitor/preferences';
112112
export function usePhotoGallery() {
113113
// Same old code from before.
114114

115-
// CHANGE: Update the `savePicture()` method.
115+
// CHANGE: Update the `savePicture()` method
116116
const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> => {
117117
// Fetch the photo, read as a blob, then convert to base64 format
118118
const response = await fetch(photo.webPath!);
@@ -133,7 +133,7 @@ export function usePhotoGallery() {
133133
};
134134
};
135135

136-
// CHANGE: Add `convertBlobToBase64()` method.
136+
// CHANGE: Add `convertBlobToBase64()` method
137137
const convertBlobToBase64 = (blob: Blob) => {
138138
return new Promise((resolve, reject) => {
139139
const reader = new FileReader();

docs/react/your-first-app/4-loading-photos.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Open `usePhotoGallery.ts` and begin by defining a constant variable that will ac
2424
```ts
2525
export function usePhotoGallery() {
2626
const [photos, setPhotos] = useState<UserPhoto[]>([]);
27-
// CHANGE: Add a key for photo storage.
27+
// CHANGE: Add a key for photo storage
2828
const PHOTO_STORAGE = 'photos';
2929

3030
// Same old code from before.
@@ -37,7 +37,7 @@ Next, at the end of the `addNewToGallery()` method, add a call to the `Preferenc
3737
const addNewToGallery = async () => {
3838
// Same old code from before.
3939

40-
// CHANGE: Add method to cache all photo data for future retrieval.
40+
// CHANGE: Add method to cache all photo data for future retrieval
4141
Preferences.set({ key: PHOTO_STORAGE, value: JSON.stringify(newPhotos) });
4242
};
4343
```
@@ -50,9 +50,9 @@ export function usePhotoGallery() {
5050

5151
const PHOTO_STORAGE = 'photos';
5252

53-
// CHANGE: Add useEffect hook.
53+
// CHANGE: Add useEffect hook
5454
useEffect(() => {
55-
// CHANGE: Add `loadSaved()` method.
55+
// CHANGE: Add `loadSaved()` method
5656
const loadSaved = async () => {
5757
const { value: photoList } = await Preferences.get({ key: PHOTO_STORAGE });
5858
const photosInPreferences = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
@@ -76,12 +76,12 @@ export function usePhotoGallery() {
7676
const PHOTO_STORAGE = 'photos';
7777

7878
useEffect(() => {
79-
// CHANGE: Update `loadSaved()` method.
79+
// CHANGE: Update `loadSaved()` method
8080
const loadSaved = async () => {
8181
const { value: photoList } = await Preferences.get({ key: PHOTO_STORAGE });
8282
const photosInPreferences = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
8383

84-
// CHANGE: Display the photo by reading into base64 format.
84+
// CHANGE: Display the photo by reading into base64 format
8585
for (const photo of photosInPreferences) {
8686
const readFile = await Filesystem.readFile({
8787
path: photo.filepath,

docs/react/your-first-app/5-adding-mobile.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { useState, useEffect } from 'react';
2828
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
2929
import { Filesystem, Directory } from '@capacitor/filesystem';
3030
import { Preferences } from '@capacitor/preferences';
31-
// CHANGE: Add imports.
31+
// CHANGE: Add imports
3232
import { isPlatform } from '@ionic/react';
3333
import { Capacitor } from '@capacitor/core';
3434

@@ -42,10 +42,10 @@ First, we’ll update the photo saving functionality to support mobile. In the `
4242
Update `savePicture()` to look like the following:
4343

4444
```ts
45-
// CHANGE: Update the `savePicture()` method.
45+
// CHANGE: Update the `savePicture()` method
4646
const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> => {
4747
let base64Data: string | Blob;
48-
// CHANGE: Add platform check.
48+
// CHANGE: Add platform check
4949
// "hybrid" will detect mobile - iOS or Android
5050
if (isPlatform('hybrid')) {
5151
const readFile = await Filesystem.readFile({
@@ -65,7 +65,7 @@ const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> =
6565
directory: Directory.Data,
6666
});
6767

68-
// CHANGE: Add platform check.
68+
// CHANGE: Add platform check
6969
if (isPlatform('hybrid')) {
7070
// Display the new image by rewriting the 'file://' path to HTTP
7171
return {
@@ -86,12 +86,12 @@ const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> =
8686
Next, add a new bit of logic in the `loadSaved()` method. On mobile, we can directly point to each photo file on the Filesystem and display them automatically. On the web, however, we must read each image from the Filesystem into base64 format. This is because the Filesystem API uses [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) under the hood. Update the `loadSaved()` method:
8787

8888
```ts
89-
// CHANGE: Update `loadSaved` method.
89+
// CHANGE: Update `loadSaved` method
9090
const loadSaved = async () => {
9191
const { value: photoList } = await Preferences.get({ key: PHOTO_STORAGE });
9292
const photosInPreferences = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
9393

94-
// CHANGE: Add platform check.
94+
// CHANGE: Add platform check
9595
// If running on the web...
9696
if (!isPlatform('hybrid')) {
9797
for (const photo of photosInPreferences) {

docs/react/your-first-app/7-live-reload.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { Capacitor } from '@capacitor/core';
5050
export function usePhotoGallery() {
5151
// Same old code from before.
5252

53-
// CHANGE: Add `deletePhoto()` method.
53+
// CHANGE: Add `deletePhoto()` method
5454
const deletePhoto = async (photo: UserPhoto) => {
5555
// Remove this photo from the Photos reference data array
5656
const newPhotos = photos.filter((p) => p.filepath !== photo.filepath);
@@ -71,7 +71,7 @@ export function usePhotoGallery() {
7171
return {
7272
photos,
7373
addNewToGallery,
74-
// CHANGE: Add `deletePhoto()` to the return statement.
74+
// CHANGE: Add `deletePhoto()` to the return statement
7575
deletePhoto,
7676
};
7777
}
@@ -86,15 +86,15 @@ Next, in `Tab2.tsx`, implement the `IonActionSheet` component. We're adding two
8686

8787
```tsx
8888
// Same old code from before.
89-
// change: Add React import.
89+
// change: Add React import
9090
import { useState } from 'react';
9191
// CHANGE: Add `UserPhoto` type import.
9292
import type { UserPhoto } from '../hooks/usePhotoGallery';
9393

9494
const Tab2: React.FC = () => {
95-
// CHANGE: Add `deletePhoto()` method.
95+
// CHANGE: Add `deletePhoto()` method
9696
const { photos, addNewToGallery, deletePhoto } = usePhotoGallery();
97-
// CHANGE: Add state for the photo to delete.
97+
// CHANGE: Add state for the photo to delete
9898
const [photoToDelete, setPhotoToDelete] = useState<UserPhoto>();
9999

100100
return (
@@ -108,7 +108,7 @@ const Tab2: React.FC = () => {
108108
</IonFabButton>
109109
</IonFab>
110110

111-
{/* CHANGE: Add action sheet for deleting photos. */}
111+
{/* CHANGE: Add action sheet for deleting photos */}
112112
<IonActionSheet
113113
isOpen={!!photoToDelete}
114114
buttons={[
@@ -147,7 +147,7 @@ Add a click handler to the `<IonImg>` element. When the app user taps on a photo
147147
<IonRow>
148148
{photos.map((photo) => (
149149
<IonCol size="6" key={photo.filepath}>
150-
{/* CHANGE: Add a click event listener to each image. */}
150+
{/* CHANGE: Add a click event listener to each image */}
151151
<IonImg src={photo.webviewPath} onClick={() => setPhotoToDelete(photo)} />
152152
</IonCol>
153153
))}

0 commit comments

Comments
 (0)