Skip to content

Commit

Permalink
DST-401: update content of compound component (#54)
Browse files Browse the repository at this point in the history
* DST-401: update content

* DST-401: add language tone

* DST-401: fix tests

* DST-401: fix vercel
  • Loading branch information
aromko authored May 31, 2024
1 parent 47e5f86 commit 6478d2d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/components/SideNavigation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ test('renders navigation links', async () => {

expect(screen.getByText('Welcome')).toBeInTheDocument();
expect(links[0]).toHaveAttribute('href', '/');
expect(screen.getByText('Compound Component')).toBeInTheDocument();
expect(screen.getByText('Compound component')).toBeInTheDocument();
expect(links[1]).toHaveAttribute('href', '/compoundComponent');
});
2 changes: 1 addition & 1 deletion src/components/SideNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SideNavigation = () => {
},
{
linkTo: '/compoundComponent',
name: 'Compound Component',
name: 'Compound component',
},
{
linkTo: '/state-management',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import BreadcrumbsExample from './BreadcrumbsExample';
import Breadcrumbs from './Breadcrumbs';

function App() {
// TODO: Replace this:
return (
<nav aria-label="Breadcrumbs">
<ol>
Expand Down Expand Up @@ -67,21 +66,17 @@ import BreadcrumbsExample from './BreadcrumbsExample';

---

## Connect the components

As final step we need to connect these components.

```tsx Breadcrumbs.tsx focus=34
// from ./Breadcrumbs.tsx
```

You can call it weird or awesome, but JS functions can have properties.
We can call it weird or awesome, but JS functions can have properties.
Functions are like objects in this way. We can "hang" data on them, like clothes hung on a clothesline.

---

## Update BreadcrumbsExample.tsx

Finally we can use this compound component in our BreadcrumbsExample.tsx.


Expand Down
8 changes: 4 additions & 4 deletions src/components/compoundComponents/Tabs/tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import TabsExample from './TabsExample';
// from ./Tabs.tsx
````
This component is essentially a wrapper that exposes the active tab state and the function that allows you to change the active tab. The context provider acts as the wrapper. So now all the children inside this container can access the activeTab and the setter function using the useContext hook.
This component is essentially a wrapper that exposes the active tab state and the function that allow us to change the active tab. The context provider acts as the wrapper. So now all the children inside this container can access the activeTab and the setter function using the useContext hook.
---
```tsx Tab.tsx
// from ./Tab.tsx
````

Then lets add the tab component. This is the button thatll help you to switch between sections.
Then lets add the tab component. This is the button thatll help us to switch between sections.
On clicking this button, it triggers the `changeTab` from the context changing the `activeTab state. Any other component that’s accessing this state will be re-rendered.
---
Expand All @@ -45,7 +45,7 @@ import TabsExample from './TabsExample';
// from ./Tabs.tsx
````
Now default export the tabs component and attach the other sub-components to this component.
Now we can default export the tabs component and attach the other sub-components to this component.
---
Expand All @@ -54,7 +54,7 @@ import TabsExample from './TabsExample';
````
Inside the TabsExample file, lets import all our tab components and use them as we please.

Note: You can add any other elements you want like the `div`. You can also use a completely different arrangement of the elements.
Note: We can add any other elements we want like the `div`. We can also use a completely different arrangement of the elements.

</CH.Scrollycoding>

Expand Down
Loading

0 comments on commit 6478d2d

Please sign in to comment.