Skip to content

Commit 536967b

Browse files
committed
Show the composition of widgets and pages
1 parent a248d97 commit 536967b

File tree

7 files changed

+58
-2
lines changed

7 files changed

+58
-2
lines changed

β€Ži18n/en/docusaurus-plugin-content-docs/current/get-started/tutorial.mdxβ€Ž

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Let's look at the principles of Feature-Sliced Design by building a simple web n
1414

1515
## Decomposing the user interface
1616

17-
Most user interfaces are made up of distinct pages or screens, so this is an easy starting point for decomposition. We have just 2 screens here (we told you it'd be simple):
17+
Most user interfaces are made up of distinct pages or screens, so this is an easy starting point for decomposition. We have just 2 screens here (told you it'd be simple!):
1818

1919
1. Note list screen, where the notes are presented for detailed reading, where you can create a new note and sign in for synchronizing your notes.
2020
2. Note creating/editing screen, where you can edit the note's title and body, as well as delete it.
@@ -34,7 +34,7 @@ Pay attention to this last action. Our application does it automatically, but it
3434

3535
### Individual UI elements that are important to the business
3636

37-
If an element is important to the business, it must either be a representation of one of the entities or an action on them. In FSD, we call them `entities` and `features` respectively.
37+
If an element is important to the business, it must either be a representation of one of the entities or an action on them. In FSD, we call them _entities_ and _features_ respectively.
3838

3939
Let's locate such elements in our UI. Try it yourself first on the image below, and then drag the slider to reveal our solution.
4040

@@ -61,3 +61,59 @@ Useful questions to ask yourself when determining whether an element is an entit
6161
/>
6262

6363
<p style={{ textAlign: "center" }}>Drag the slider above from right to left!</p>
64+
65+
### Combining entities and features into meaningful blocks
66+
67+
Now that we have our entities and features identified and separated, we can start putting them together. In Feature-Sliced Design, we do this in the compositional layers: _Widgets_ and _Pages_. As you may have guessed from the name, one is used to compose blocks of the UI, and the other is used to compose entire screens. Let's identify the blocks that make up our application:
68+
69+
<ReactCompareSlider
70+
handle={<ReactCompareSliderHandle buttonStyle={{WebkitBackdropFilter: undefined, backdropFilter: undefined, backgroundColor: 'white', boxShadow: undefined, color: '#444'}} linesStyle={{opacity: 0.5}}/>}
71+
itemOne={<ThemedCompareSliderImage srcLight="/img/tutorial/overview-light.jpg" srcDark="/img/tutorial/overview-dark.jpg" alt="Screens, unannotated" />}
72+
itemTwo={<ThemedCompareSliderImage srcLight="/img/tutorial/annotated-widgets-light.jpg" srcDark="/img/tutorial/annotated-widgets-dark.jpg" alt="Screens, annotated with widgets" />}
73+
position={0}
74+
/>
75+
76+
We have three different blocks here: a note card, a note editor, and the application bar. A note card, for example, is made up of a UI skeleton, the data, and an external link component to handle navigation on click. It is a small component, so we can compose it on the Widgets layer:
77+
78+
![Note card composition](/img/tutorial/note-card-composition-light.jpg#light-mode-only)
79+
![Note card composition](/img/tutorial/note-card-composition-dark.jpg#dark-mode-only)
80+
81+
The note editor in our case is a complete page, so we will compose it on the Pages layer. It's also more complicated, so there are more components involved. We have a skeleton again, the data to populate the editor, the editor component itself, a link button from our internal UI kit that handles navigation, and a button to delete the note, coupled with the click handler:
82+
83+
![Note editor composition](/img/tutorial/edit-note-composition-light.jpg#light-mode-only)
84+
![Note editor composition](/img/tutorial/edit-note-composition-dark.jpg#dark-mode-only)
85+
86+
Note that we have a UI skeleton component inside `pages/edit-note/ui/`, and the composed component is also in this folder. Sometimes it's more practical to have smaller components like this simply alongside the main component of the slice as opposed to having them in layers below (like the note card skeleton in the previous example).
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
<!--
114+
115+
You may be used to a much less granular decomposition. You might have used the terms `containers` and `components` before. In FSD, we have _widgets_ for that. Widgets usually represent large blocks of an interface that you can easily identify with your eyes.
116+
117+
118+
119+
-->
367 KB
Loading
383 KB
Loading
536 KB
Loading
568 KB
Loading
264 KB
Loading
282 KB
Loading

0 commit comments

Comments
Β (0)