You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will take a moment for the Sass to compile. Once compiled, you'll notice that the Carbon base styling is applied (IBM Plex Sans font family, font size, weight, colors, etc.)
167
161
168
162
Because any change to `index.scss` will re-compile all of the Carbon Sass, create an `app.scss` file in the `src` directory and in `App.js`, import that new file.
169
163
170
-
##### src/App.js
171
-
172
-
```javascript
164
+
```javascript path=src/App.js
173
165
import'./app.scss';
174
166
```
175
167
176
168
_Note: To optimize our Sass compile time, we'll be adding app-specific styling to_`app.scss`_and only modifying_`index.scss`_when necessary._
177
169
178
170
Next we'll import a `Button` from Carbon to test that our dependencies are working properly. At the top of `App.js`, import the `Button` by adding the following:
179
171
180
-
##### src/App.js
181
-
182
-
```javascript
172
+
```javascript path=src/App.js
183
173
import { Button } from'carbon-components-react';
184
174
```
185
175
186
176
In the `App` component return, you can now replace:
@@ -295,27 +273,21 @@ _Note: It's important that the_ `TutorialHeader` _returns the Carbon_ `Header` _
295
273
296
274
Now let's import the icons from our `@carbon/icons-react` elements package. In the `TutorialHeader.js` file, we need to import each individual icon we will use.
import Notification20 from '@carbon/icons-react/lib/notification/20';
302
278
import UserAvatar20 from '@carbon/icons-react/lib/user--avatar/20';
303
279
import AppSwitcher20 from '@carbon/icons-react/lib/app-switcher/20';
304
280
```
305
281
306
282
Then we need to add the `HeaderGlobalAction` component inside of the `HeaderGlobalBar` where we will add our icons. These represent actions in the header a user can make. Replace:
@@ -412,18 +378,14 @@ Next, we'll import our content Sass files in `app.scss`, like so:
412
378
413
379
Now that our stylesheets are set up, we need to create our pages' components. Starting with `LandingPage`, just like with our header, we need to export the component in `src/content/LandingPage/index.js` by adding:
_Note: We're using_`HashRouter`_instead of_`BrowserRouter`_to simplify deployments in upcoming tutorial steps. Learn more about the React Router [here](https://reacttraining.com/react-router/web/api/BrowserRouter)._
481
437
482
438
Then, update the `render()` function to include the `Router`.
483
439
484
-
##### src/index.js
485
-
486
-
```javascript
440
+
```javascript path=src/index.js
487
441
ReactDOM.render(
488
442
<Router>
489
443
<App />
@@ -494,9 +448,7 @@ ReactDOM.render(
494
448
495
449
In order to render our content pages, we need to add the following imports in `App.js` below our existing imports.
496
450
497
-
##### src/App.js
498
-
499
-
```javascript
451
+
```javascript path=src/App.js
500
452
import { Route, Switch } from'react-router-dom';
501
453
importLandingPagefrom'./content/LandingPage';
502
454
importRepoPagefrom'./content/RepoPage';
@@ -508,10 +460,8 @@ Next thing we need to is update what we're returning in `App.js` . We currently
508
460
509
461
Now inside `Content` we'll add the following:
510
462
511
-
##### src/App.js
512
-
513
463
<!--prettier-ignore-start-->
514
-
```html
464
+
```htmlpath=src/App.js
515
465
<Switch>
516
466
<Routeexactpath="/"component={LandingPage} />
517
467
<Routepath="/repos"component={RepoPage} />
@@ -523,27 +473,21 @@ After that we need to do a couple quick fixes to the UI Shell to have it work wi
We need to use the `Link` component instead of the default anchor elements to prevent full page reload when navigating to different pages with React Router. To use `Link`, update the `HeaderName` component to use the `element` prop and replace the `href` with `to`:
0 commit comments