@iress-oss/ids-mcp-server 0.0.1-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +201 -0
- package/README.md +93 -0
- package/dist/componentHandlers.js +241 -0
- package/dist/componentHandlers.test.js +380 -0
- package/dist/config.js +16 -0
- package/dist/index.js +53 -0
- package/dist/iressHandlers.js +144 -0
- package/dist/iressHandlers.test.js +316 -0
- package/dist/resourceHandlers.js +67 -0
- package/dist/resourceHandlers.test.js +352 -0
- package/dist/searchHandlers.js +287 -0
- package/dist/searchHandlers.test.js +524 -0
- package/dist/toolHandler.js +31 -0
- package/dist/toolHandler.test.js +369 -0
- package/dist/tools.js +165 -0
- package/dist/types.js +4 -0
- package/dist/utils.js +59 -0
- package/dist/utils.test.js +286 -0
- package/generated/docs/components-alert-docs.md +130 -0
- package/generated/docs/components-autocomplete-docs.md +754 -0
- package/generated/docs/components-autocomplete-recipes-docs.md +104 -0
- package/generated/docs/components-badge-docs.md +148 -0
- package/generated/docs/components-button-docs.md +362 -0
- package/generated/docs/components-button-recipes-docs.md +76 -0
- package/generated/docs/components-buttongroup-docs.md +310 -0
- package/generated/docs/components-card-docs.md +494 -0
- package/generated/docs/components-card-recipes-docs.md +89 -0
- package/generated/docs/components-checkbox-docs.md +193 -0
- package/generated/docs/components-checkboxgroup-docs.md +692 -0
- package/generated/docs/components-checkboxgroup-recipes-docs.md +119 -0
- package/generated/docs/components-col-docs.md +466 -0
- package/generated/docs/components-combobox-docs.md +1016 -0
- package/generated/docs/components-container-docs.md +91 -0
- package/generated/docs/components-divider-docs.md +176 -0
- package/generated/docs/components-expander-docs.md +215 -0
- package/generated/docs/components-field-docs.md +675 -0
- package/generated/docs/components-filter-docs.md +1109 -0
- package/generated/docs/components-form-docs.md +2442 -0
- package/generated/docs/components-form-recipes-docs.md +892 -0
- package/generated/docs/components-hide-docs.md +265 -0
- package/generated/docs/components-icon-docs.md +553 -0
- package/generated/docs/components-inline-docs.md +868 -0
- package/generated/docs/components-input-docs.md +335 -0
- package/generated/docs/components-input-recipes-docs.md +140 -0
- package/generated/docs/components-inputcurrency-docs.md +157 -0
- package/generated/docs/components-inputcurrency-recipes-docs.md +116 -0
- package/generated/docs/components-label-docs.md +135 -0
- package/generated/docs/components-menu-docs.md +704 -0
- package/generated/docs/components-menu-menuitem-docs.md +193 -0
- package/generated/docs/components-modal-docs.md +587 -0
- package/generated/docs/components-navbar-docs.md +291 -0
- package/generated/docs/components-navbar-recipes-docs.md +413 -0
- package/generated/docs/components-panel-docs.md +380 -0
- package/generated/docs/components-placeholder-docs.md +27 -0
- package/generated/docs/components-popover-docs.md +464 -0
- package/generated/docs/components-popover-recipes-docs.md +245 -0
- package/generated/docs/components-progress-docs.md +104 -0
- package/generated/docs/components-radio-docs.md +107 -0
- package/generated/docs/components-radiogroup-docs.md +683 -0
- package/generated/docs/components-readonly-docs.md +89 -0
- package/generated/docs/components-richselect-docs.md +2433 -0
- package/generated/docs/components-row-docs.md +877 -0
- package/generated/docs/components-select-docs.md +456 -0
- package/generated/docs/components-skeleton-docs.md +214 -0
- package/generated/docs/components-skeleton-recipes-docs.md +76 -0
- package/generated/docs/components-skiplink-docs.md +66 -0
- package/generated/docs/components-slideout-docs.md +538 -0
- package/generated/docs/components-slider-docs.md +346 -0
- package/generated/docs/components-spinner-docs.md +59 -0
- package/generated/docs/components-stack-docs.md +265 -0
- package/generated/docs/components-table-ag-grid-docs.md +2666 -0
- package/generated/docs/components-table-docs.md +1305 -0
- package/generated/docs/components-tabset-docs.md +341 -0
- package/generated/docs/components-tabset-tab-docs.md +86 -0
- package/generated/docs/components-tag-docs.md +115 -0
- package/generated/docs/components-text-docs.md +394 -0
- package/generated/docs/components-toaster-docs.md +294 -0
- package/generated/docs/components-toaster-toast-docs.md +157 -0
- package/generated/docs/components-toggle-docs.md +158 -0
- package/generated/docs/components-tooltip-docs.md +311 -0
- package/generated/docs/components-validationmessage-docs.md +241 -0
- package/generated/docs/contact-us-docs.md +27 -0
- package/generated/docs/extensions-editor-docs.md +288 -0
- package/generated/docs/extensions-editor-recipes-docs.md +39 -0
- package/generated/docs/foundations-accessibility-docs.md +62 -0
- package/generated/docs/foundations-colours-docs.md +257 -0
- package/generated/docs/foundations-consistency-docs.md +52 -0
- package/generated/docs/foundations-content-docs.md +23 -0
- package/generated/docs/foundations-introduction-docs.md +17 -0
- package/generated/docs/foundations-principles-docs.md +70 -0
- package/generated/docs/foundations-typography-docs.md +191 -0
- package/generated/docs/foundations-user-experience-docs.md +63 -0
- package/generated/docs/foundations-visual-design-docs.md +46 -0
- package/generated/docs/frequently-asked-questions-docs.md +53 -0
- package/generated/docs/get-started-develop-docs.md +48 -0
- package/generated/docs/get-started-using-storybook-docs.md +68 -0
- package/generated/docs/guidelines.md +812 -0
- package/generated/docs/introduction-docs.md +43 -0
- package/generated/docs/patterns-loading-docs.md +1304 -0
- package/generated/docs/resources-changelog-docs.md +6 -0
- package/generated/docs/resources-code-katas-docs.md +29 -0
- package/generated/docs/resources-migration-guides-from-v4-to-v5-docs.md +437 -0
- package/generated/docs/themes-available-themes-docs.md +66 -0
- package/generated/docs/themes-introduction-docs.md +121 -0
- package/generated/docs/themes-tokens-docs.md +1200 -0
- package/generated/docs/versions-docs.md +17 -0
- package/package.json +81 -0
|
@@ -0,0 +1,1304 @@
|
|
|
1
|
+
[](#loading)Loading
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
Overview
|
|
5
|
+
--------
|
|
6
|
+
|
|
7
|
+
The loading pattern is used to indicate that content is being loaded or processed consistently across Iress products. It can be used in various scenarios, such as loading entire applications, pages, components or server-side validation.
|
|
8
|
+
|
|
9
|
+
* * *
|
|
10
|
+
|
|
11
|
+
Beta
|
|
12
|
+
|
|
13
|
+
New component
|
|
14
|
+
|
|
15
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
16
|
+
|
|
17
|
+
Hide codeRefresh
|
|
18
|
+
|
|
19
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
20
|
+
|
|
21
|
+
interface PageProps {
|
|
22
|
+
setPage: (page: number) \=> void;
|
|
23
|
+
}
|
|
24
|
+
interface ChartProps {
|
|
25
|
+
money: number | null;
|
|
26
|
+
}
|
|
27
|
+
const API \= {
|
|
28
|
+
initialise: async () \=>
|
|
29
|
+
new Promise<boolean\>((resolve) \=> {
|
|
30
|
+
// Simulate a slow network request.
|
|
31
|
+
setTimeout(() \=> {
|
|
32
|
+
resolve(true);
|
|
33
|
+
}, 3000);
|
|
34
|
+
}),
|
|
35
|
+
data: async () \=>
|
|
36
|
+
new Promise<boolean\>((resolve) \=> {
|
|
37
|
+
// Simulate a slow network request.
|
|
38
|
+
setTimeout(() \=> {
|
|
39
|
+
resolve(true);
|
|
40
|
+
}, 2000);
|
|
41
|
+
}),
|
|
42
|
+
chart: async () \=>
|
|
43
|
+
new Promise<boolean\>((resolve) \=> {
|
|
44
|
+
// Simulate a slow network request.
|
|
45
|
+
setTimeout(() \=> {
|
|
46
|
+
resolve(true);
|
|
47
|
+
}, 2000);
|
|
48
|
+
}),
|
|
49
|
+
chartUpdate: async () \=>
|
|
50
|
+
new Promise<boolean\>((resolve) \=> {
|
|
51
|
+
// Simulate a slow network request.
|
|
52
|
+
setTimeout(() \=> {
|
|
53
|
+
resolve(true);
|
|
54
|
+
}, 2000);
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
const Graph \= () \=> (
|
|
58
|
+
<img
|
|
59
|
+
src\={retirementGraph}
|
|
60
|
+
alt\=""
|
|
61
|
+
style\={{ maxWidth: '100%', height: 'auto' }}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
const Chart \= () \=> {
|
|
65
|
+
const \[chart, setChart\] \= useState(false);
|
|
66
|
+
const \[money, setMoney\] \= useState<number | null\>(null);
|
|
67
|
+
const \[loaded, setLoaded\] \= useState(false);
|
|
68
|
+
const \[updating, setUpdating\] \= useState(false);
|
|
69
|
+
const safeLoaded \= IressLoading.shouldRender(loaded);
|
|
70
|
+
const deferredMoney \= useDeferredValue(money);
|
|
71
|
+
useEffect(() \=> {
|
|
72
|
+
const initialise \= async () \=> {
|
|
73
|
+
const newChart \= await API.chart();
|
|
74
|
+
setChart(newChart);
|
|
75
|
+
setLoaded(() \=> true);
|
|
76
|
+
};
|
|
77
|
+
void initialise();
|
|
78
|
+
}, \[\]);
|
|
79
|
+
useEffect(() \=> {
|
|
80
|
+
if (deferredMoney \=== null) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setUpdating(() \=> true);
|
|
84
|
+
const update \= async () \=> {
|
|
85
|
+
const newChart \= await API.chartUpdate();
|
|
86
|
+
setChart(newChart);
|
|
87
|
+
setUpdating(() \=> false);
|
|
88
|
+
};
|
|
89
|
+
void update();
|
|
90
|
+
}, \[deferredMoney\]);
|
|
91
|
+
return (
|
|
92
|
+
<IressLoading pattern\="component" loaded\={!safeLoaded} update\={updating}\>
|
|
93
|
+
{chart && <Graph />}
|
|
94
|
+
<IressPanel\>
|
|
95
|
+
<IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
|
|
96
|
+
> <IressStack gutter\="md"\>
|
|
97
|
+
<h3\>Update projection</h3\>
|
|
98
|
+
<IressFormField
|
|
99
|
+
name\="money"
|
|
100
|
+
label\="My money"
|
|
101
|
+
render\={(controlledProps) \=> (
|
|
102
|
+
<IressInputCurrency {...controlledProps} />
|
|
103
|
+
)}
|
|
104
|
+
/>
|
|
105
|
+
<IressButton type\="submit"\>Update projection</IressButton\>
|
|
106
|
+
</IressStack\>
|
|
107
|
+
</IressForm\>
|
|
108
|
+
</IressPanel\>
|
|
109
|
+
</IressLoading\>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
const StartPage \= ({ setPage }: PageProps) \=> (
|
|
113
|
+
<IressText\>
|
|
114
|
+
<h2\>Maximise your retirement</h2\>
|
|
115
|
+
<p\>
|
|
116
|
+
Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
|
|
117
|
+
<hr />
|
|
118
|
+
<IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
|
|
119
|
+
</IressText\>
|
|
120
|
+
);
|
|
121
|
+
const RetirementIncomeProjectionPage \= () \=> {
|
|
122
|
+
const \[data, setData\] \= useState(false);
|
|
123
|
+
const loaded \= data !== false;
|
|
124
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
125
|
+
useEffect(() \=> {
|
|
126
|
+
const initialise \= async () \=> {
|
|
127
|
+
const newData \= await API.data();
|
|
128
|
+
setData(newData);
|
|
129
|
+
};
|
|
130
|
+
void initialise();
|
|
131
|
+
}, \[\]);
|
|
132
|
+
if (renderLoading) {
|
|
133
|
+
return <IressLoading pattern\="page" template\="form" loaded\={loaded} />;
|
|
134
|
+
}
|
|
135
|
+
return (
|
|
136
|
+
<IressText\>
|
|
137
|
+
<h2\>Retirement Income Projection</h2\>
|
|
138
|
+
<p\>
|
|
139
|
+
We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
|
|
140
|
+
<Chart />
|
|
141
|
+
</IressText\>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
export const LoadingWizard \= () \=> {
|
|
145
|
+
const \[page, setPage\] \= useState(0);
|
|
146
|
+
const loaded \= page \> 0;
|
|
147
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
148
|
+
useEffect(() \=> {
|
|
149
|
+
const initialise \= async () \=> {
|
|
150
|
+
await API.initialise();
|
|
151
|
+
setPage(1);
|
|
152
|
+
};
|
|
153
|
+
void initialise();
|
|
154
|
+
}, \[\]);
|
|
155
|
+
if (renderLoading) {
|
|
156
|
+
return <IressLoading pattern\="start-up" loaded\={loaded} />;
|
|
157
|
+
}
|
|
158
|
+
return (
|
|
159
|
+
<IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
|
|
160
|
+
{page \=== 1 && <StartPage setPage\={setPage} />}
|
|
161
|
+
{page \=== 2 && <RetirementIncomeProjectionPage />}
|
|
162
|
+
</IressContainer\>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
Copy
|
|
167
|
+
|
|
168
|
+
[](#usage)Usage
|
|
169
|
+
---------------
|
|
170
|
+
|
|
171
|
+
The main prop for the `IressLoading` component is the `pattern` prop. This prop determines the type of loading pattern to be used. The available options are:
|
|
172
|
+
|
|
173
|
+
1. `component`: This pattern is used to indicate that a specific component is loading. It is typically used when the there is a slower compoent on the page that requires its own loading state. Examples include:
|
|
174
|
+
* Loading a table with a large number of rows
|
|
175
|
+
* Loading a chart with a large number of data points
|
|
176
|
+
2. `default`: This pattern is used when no other pattern matches a scenario, and will only indicate loading if something is taking a long time to load. It is used when long loading times are not expected. Examples include:
|
|
177
|
+
* Navigation
|
|
178
|
+
3. `long`: Loading pattern for a component that is expected to take longer than 10 seconds to load. It displays a checklist of items that are being loaded. Examples:
|
|
179
|
+
* Calling multiple slow APIs to load data
|
|
180
|
+
* Loading results from AI
|
|
181
|
+
* Processing a large amount of data as a queue (eg. bulk uploading or large media file uploads)
|
|
182
|
+
4. `page`: This pattern is used to indicate that a page is loading. It is the most common loading pattern, allowing the users to see the entire content at once where possible. Examples include:
|
|
183
|
+
* Detail page for a record
|
|
184
|
+
* Form/Article page
|
|
185
|
+
* Dashboard page
|
|
186
|
+
5. `start-up`: This pattern is used to indicate that the application is loading. It is typically used when the application is first launched. Examples include:
|
|
187
|
+
* Loading a new application
|
|
188
|
+
* Switching from a different application to a new application
|
|
189
|
+
* Switching from a client's website to an Iress application
|
|
190
|
+
* Switching themes
|
|
191
|
+
6. `validate`: This pattern is used to indicate that a server-side validation is in progress. It is typically used when the user is submitting a form or performing an action that requires validation. Examples include:
|
|
192
|
+
* Submitting a form
|
|
193
|
+
* Saving a record
|
|
194
|
+
|
|
195
|
+
It is **recommended** to read the Patterns section of the documentation to understand how to use the loading patterns effectively.
|
|
196
|
+
|
|
197
|
+
### [](#be-consistent)Be consistent
|
|
198
|
+
|
|
199
|
+
Apart from using the `IressLoading` component, there are a few things you need to do to ensure you are using the loading patterns correctly to ensure consistency across Iress products.
|
|
200
|
+
|
|
201
|
+
* Consider the difference between what the system is doing and what the user is doing. For example, when a user is submitting a form, the system may be calling different APIs and you may be tempted to use the different loading patterns for each API. However, the user is only submitting the form once, so you should only use one loading pattern for the entire form submission process. In most cases, it will be the `page` loading pattern.
|
|
202
|
+
* When switch between different applications, consider using the same loading pattern. This will help mask the loading time and improve the user experience.
|
|
203
|
+
|
|
204
|
+
[](#behaviour)Behaviour
|
|
205
|
+
-----------------------
|
|
206
|
+
|
|
207
|
+
The `IressLoading` component is designed to create a seamless experience for users when loading content. They have been designed to meet best practices and improve user perception of loading times.
|
|
208
|
+
|
|
209
|
+

|
|
210
|
+
|
|
211
|
+
Image © [UX Collective](https://uxdesign.cc/loading-progress-indicators-ui-components-series-f4b1fc35339a)
|
|
212
|
+
|
|
213
|
+
* * *
|
|
214
|
+
|
|
215
|
+
To match the above image, the default behaviour of the loading patterns are as follows:
|
|
216
|
+
|
|
217
|
+
* Between 0 - 500ms: No loading indicator, it will be assumed that the content is already loaded.
|
|
218
|
+
* Between 500ms - 2 seconds: A loading indicator will animate in. It will either be a skeleton or a progress bar.
|
|
219
|
+
* Between 2 - 5 seconds: A loading message will animate in.
|
|
220
|
+
* Between 5 - 10 seconds: Some components support additional loading messages. These will animate in and out to indicate that the content is still loading and as well as give the user the perception something is happening in the background.
|
|
221
|
+
* After 10 seconds: Components display a list of messages to indicate what actions the system is doing to complete the user's request. These are checked off as they are completed. This is to give the user the perception that something is happening in the background and to keep them informed of what is happening.
|
|
222
|
+
|
|
223
|
+
In future releases, we will be adding support for the following:
|
|
224
|
+
|
|
225
|
+
* After 10 seconds (background): it is always best not to block the user from using the application even if the system is busy. This will be a future feature of the `long` loading pattern.
|
|
226
|
+
|
|
227
|
+
* * *
|
|
228
|
+
|
|
229
|
+
The `IressLoading` patterns have been built using `IressSkeleton`, `IressSpinner` and `IressProgressBar` and other components, reducing the need to create custom loading components.
|
|
230
|
+
|
|
231
|
+
[](#patterns)Patterns
|
|
232
|
+
---------------------
|
|
233
|
+
|
|
234
|
+
### [](#component)`component`
|
|
235
|
+
|
|
236
|
+
The `component` loading pattern is used to indicate that a specific component is loading. It is typically used when the there is a slower component on the page that requires its own loading state. You would usually use this pattern when loading data visualisations such as charts and tables.
|
|
237
|
+
|
|
238
|
+
#### [](#behavior)Behavior
|
|
239
|
+
|
|
240
|
+
1. When `loaded` is false, a skeleton will be displayed immediately (configured using `timeout.skeleton`). This skeleton can be customised using the `template` prop.
|
|
241
|
+
2. When `loaded` is true, the skeleton will be removed and the `children` will be displayed.
|
|
242
|
+
3. When `updated` is true, the `children` will be faded out to indicate the component is loading.
|
|
243
|
+
4. After 1000ms (configured using `timeout.update`), the `Updating...` message will be fade in. This message can be customised using the `updated` prop.
|
|
244
|
+
|
|
245
|
+
#### [](#custom-skeletons)Custom skeletons
|
|
246
|
+
|
|
247
|
+
The skeleton representing the component should be as simple as possible, it does not need to be a perfect representation of the component. In most cases a simple rectangle is sufficient that takes up the approximate same space as the component that is loading.
|
|
248
|
+
|
|
249
|
+
* * *
|
|
250
|
+
|
|
251
|
+
Beta
|
|
252
|
+
|
|
253
|
+
New component
|
|
254
|
+
|
|
255
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
256
|
+
|
|
257
|
+

|
|
258
|
+
|
|
259
|
+
Update
|
|
260
|
+
|
|
261
|
+
Hide codeRefresh
|
|
262
|
+
|
|
263
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
264
|
+
|
|
265
|
+
const API \= {
|
|
266
|
+
chart: async () \=>
|
|
267
|
+
new Promise<boolean\>((resolve) \=> {
|
|
268
|
+
// Simulate a slow network request.
|
|
269
|
+
setTimeout(() \=> {
|
|
270
|
+
resolve(true);
|
|
271
|
+
}, 2000);
|
|
272
|
+
}),
|
|
273
|
+
chartUpdate: async () \=>
|
|
274
|
+
new Promise<boolean\>((resolve) \=> {
|
|
275
|
+
// Simulate a slow network request.
|
|
276
|
+
setTimeout(() \=> {
|
|
277
|
+
resolve(true);
|
|
278
|
+
}, 2000);
|
|
279
|
+
}),
|
|
280
|
+
};
|
|
281
|
+
const Graph \= () \=> (
|
|
282
|
+
<img
|
|
283
|
+
src\={retirementGraph}
|
|
284
|
+
alt\=""
|
|
285
|
+
style\={{ maxWidth: '100%', height: 'auto' }}
|
|
286
|
+
/>
|
|
287
|
+
);
|
|
288
|
+
export const LoadingGraph \= () \=> {
|
|
289
|
+
const \[graph, setGraph\] \= useState(false);
|
|
290
|
+
const \[updating, setUpdating\] \= useState(false);
|
|
291
|
+
const renderLoading \= IressLoading.shouldRender(graph);
|
|
292
|
+
const doUpdate \= useCallback(() \=> {
|
|
293
|
+
const update \= async () \=> {
|
|
294
|
+
await API.chartUpdate();
|
|
295
|
+
setUpdating(false);
|
|
296
|
+
};
|
|
297
|
+
setUpdating(true);
|
|
298
|
+
void update();
|
|
299
|
+
}, \[\]);
|
|
300
|
+
useEffect(() \=> {
|
|
301
|
+
const initialise \= async () \=> {
|
|
302
|
+
setGraph(await API.chart());
|
|
303
|
+
};
|
|
304
|
+
void initialise();
|
|
305
|
+
}, \[\]);
|
|
306
|
+
return (
|
|
307
|
+
<IressLoading
|
|
308
|
+
pattern\="component"
|
|
309
|
+
template\="chart"
|
|
310
|
+
loaded\={!renderLoading}
|
|
311
|
+
update\={updating}
|
|
312
|
+
\>
|
|
313
|
+
<IressStack gutter\="md" style\={{ display: 'inline-block' }}\>
|
|
314
|
+
<div\>
|
|
315
|
+
<Graph />
|
|
316
|
+
</div\>
|
|
317
|
+
<IressButton onClick\={doUpdate}\>Update</IressButton\>
|
|
318
|
+
</IressStack\>
|
|
319
|
+
</IressLoading\>
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
Copy
|
|
324
|
+
|
|
325
|
+
### [](#default)`default`
|
|
326
|
+
|
|
327
|
+
The `default` loading pattern is used when no other pattern matches a scenario, and will only indicate loading if something is taking a long time to load. It is used when long loading times are not expected.
|
|
328
|
+
|
|
329
|
+
This pattern is used when the user is navigating between different pages or sections of the application.
|
|
330
|
+
|
|
331
|
+
#### [](#behavior-1)Behavior
|
|
332
|
+
|
|
333
|
+
1. Displays nothing by default
|
|
334
|
+
|
|
335
|
+
2. After 3000ms (configured using `timeout`), the `This is taking longer than expected...` message will be slide in from top center. This message can be customised using the `children` prop.
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
* * *
|
|
339
|
+
|
|
340
|
+
Beta
|
|
341
|
+
|
|
342
|
+
New component
|
|
343
|
+
|
|
344
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
345
|
+
|
|
346
|
+
This is taking longer than expected...
|
|
347
|
+
|
|
348
|
+
Hide codeRefresh
|
|
349
|
+
|
|
350
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
351
|
+
|
|
352
|
+
<IressLoading pattern\="default" />
|
|
353
|
+
|
|
354
|
+
Copy
|
|
355
|
+
|
|
356
|
+
### [](#long)`long`
|
|
357
|
+
|
|
358
|
+
The `long` loading pattern is used to indicate an expected long loading time, usually longer than 10 seconds to complete. It is typically used when calling multiple third-party APIs, AI generation and other long running tasks.
|
|
359
|
+
|
|
360
|
+
It has a required prop, `messageList`, which is an object map where the key is the time you want the message to be marked as completed and the value is the message to display. The messages will be completed (checked off) as the time elapses.
|
|
361
|
+
|
|
362
|
+
#### [](#behavior-2)Behavior
|
|
363
|
+
|
|
364
|
+
1. When `loaded` is false, a progress bar and check list will be displayed after 500ms (configured using `timeout.message`). This progress bar can be customised using the `renderProgress` prop.
|
|
365
|
+
2. The messages will rotate until the `loaded` prop is set to true.
|
|
366
|
+
* When a message falls within its elapsed time, it will be displayed with an animated ellipsis, indicating that the system is still working on it.
|
|
367
|
+
* When a message is completed, it will be displayed with a check mark.
|
|
368
|
+
3. When `loaded` is true, all items in the checklist are completed and the progress bar and message will begin fading out. To see the fade out, you will need to use the `IressLoading.shouldRender` hook.
|
|
369
|
+
4. When `error` is true, the error message will be displayed, overriding the progress bar and checklist. This message can be customised using the `error` prop. The error message will be displayed with a red background.
|
|
370
|
+
|
|
371
|
+
#### [](#adjusting-the-progress-bar)Adjusting the progress bar
|
|
372
|
+
|
|
373
|
+
The `long` loading pattern uses a progress bar to indicate that the application is loading alongside an `estimatedFinishTime` prop. This prop is used to indicate the estimated time until the application is fully loaded, and is used to help the user understand how long they will need to wait and assure them something is happening. The progress bar will animate based on the estimated time.
|
|
374
|
+
|
|
375
|
+
If your application is capable of calculating real progress, you can pass the `progress` prop to the `IressLoading` component and that value will be used instead.
|
|
376
|
+
|
|
377
|
+
Once the `loaded` prop is set to true, the progress bar will always be set to 100% and the loading pattern will fade out.
|
|
378
|
+
|
|
379
|
+
* * *
|
|
380
|
+
|
|
381
|
+
Beta
|
|
382
|
+
|
|
383
|
+
New component
|
|
384
|
+
|
|
385
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
386
|
+
|
|
387
|
+
* Finished: Processing transcript
|
|
388
|
+
* Finished: Noting key information
|
|
389
|
+
* Finished: Generating summary...
|
|
390
|
+
|
|
391
|
+
Hide codeRefresh
|
|
392
|
+
|
|
393
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
394
|
+
|
|
395
|
+
<IressLoading
|
|
396
|
+
messageList\={{
|
|
397
|
+
'3000': 'Processing transcript',
|
|
398
|
+
'5000': 'Noting key information',
|
|
399
|
+
'7000': 'Generating summary'
|
|
400
|
+
}}
|
|
401
|
+
pattern\="long"
|
|
402
|
+
/>
|
|
403
|
+
|
|
404
|
+
Copy
|
|
405
|
+
|
|
406
|
+
### [](#page)`page`
|
|
407
|
+
|
|
408
|
+
The `page` loading pattern is used to indicate that a page is loading. It is the most common loading pattern, allowing the users to see the entire content at once where possible.
|
|
409
|
+
|
|
410
|
+
#### [](#behavior-3)Behavior
|
|
411
|
+
|
|
412
|
+
1. When `loaded` is false, a skeleton will be displayed after 500ms (configured using `timeout`). This skeleton can be customised using the `template` prop.
|
|
413
|
+
2. If `critical` is set whilst `loaded` is false, the critical content will be displayed immediately. This is useful for showing critical content while the rest of the page is loading.
|
|
414
|
+
3. When `loaded` is true, the skeleton will begin fading out. To see the fade out, you will need to use the `IressLoading.shouldRender` hook.
|
|
415
|
+
|
|
416
|
+
#### [](#custom-skeletons-1)Custom skeletons
|
|
417
|
+
|
|
418
|
+
The skeleton does not need to be a perfect representation of the page. It is recommended to follow the guidelines below when creating custom `template` skeletons:
|
|
419
|
+
|
|
420
|
+
* If there are multiple rows, only create a skeleton of the first row. This is enough to give the user an idea of what the content will look like.
|
|
421
|
+
* If there are multiple filters, only create a few filters in the general area where they will appear.
|
|
422
|
+
* For cards, keep the skeleton as simple as possible. It does not need to be a perfect representation of the card. In most cases a title, description and image is sufficient.
|
|
423
|
+
|
|
424
|
+
For your convenience, we have provided a few templates that you can use in the `template` prop, including: `page`, `form` and `dashboard`.
|
|
425
|
+
|
|
426
|
+
#### [](#critical-content)Critical content
|
|
427
|
+
|
|
428
|
+
In some cases it may be useful to show critical content while the rest of the page is loading. This gives the user a preview of what to expect. The example below shows a loading page with critical content by using the `critical` prop.
|
|
429
|
+
|
|
430
|
+
* * *
|
|
431
|
+
|
|
432
|
+
Beta
|
|
433
|
+
|
|
434
|
+
New component
|
|
435
|
+
|
|
436
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
437
|
+
|
|
438
|
+
Dashboard
|
|
439
|
+
=========
|
|
440
|
+
|
|
441
|
+
* * *
|
|
442
|
+
|
|
443
|
+
### Financial update 2025
|
|
444
|
+
|
|
445
|
+
### The ASX update
|
|
446
|
+
|
|
447
|
+
### In the news
|
|
448
|
+
|
|
449
|
+
Loading...
|
|
450
|
+
|
|
451
|
+
Hide codeRefresh
|
|
452
|
+
|
|
453
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
454
|
+
|
|
455
|
+
const API \= {
|
|
456
|
+
criticalContent: async () \=>
|
|
457
|
+
new Promise<ReactNode\>((resolve) \=> {
|
|
458
|
+
// Simulate a slow network request.
|
|
459
|
+
setTimeout(() \=> {
|
|
460
|
+
resolve(
|
|
461
|
+
<IressContainer\>
|
|
462
|
+
<IressStack gutter\="lg"\>
|
|
463
|
+
<IressRow horizontalAlign\="between" verticalAlign\="middle"\>
|
|
464
|
+
<IressText element\="h1" noGutter\>
|
|
465
|
+
Dashboard </IressText\>
|
|
466
|
+
<IressInline gutter\="lg"\>
|
|
467
|
+
<IressSkeleton textVariant\="lead" width\="200px" />
|
|
468
|
+
<IressSkeleton textVariant\="lead" width\="200px" />
|
|
469
|
+
</IressInline\>
|
|
470
|
+
</IressRow\>
|
|
471
|
+
<IressDivider />
|
|
472
|
+
<IressRow gutter\="lg"\>
|
|
473
|
+
<IressCol span\="4"\>
|
|
474
|
+
<IressCard stretch\>
|
|
475
|
+
<IressStack gutter\="md"\>
|
|
476
|
+
<IressSkeleton mode\="rect" height\="300px" />
|
|
477
|
+
<IressText element\="h3"\>Financial update 2025</IressText\>
|
|
478
|
+
<IressSkeleton textVariant\="body" width\="50%" />
|
|
479
|
+
</IressStack\>
|
|
480
|
+
</IressCard\>
|
|
481
|
+
</IressCol\>
|
|
482
|
+
<IressCol span\="4"\>
|
|
483
|
+
<IressCard stretch\>
|
|
484
|
+
<IressStack gutter\="md"\>
|
|
485
|
+
<IressSkeleton mode\="rect" height\="300px" />
|
|
486
|
+
<IressText element\="h3"\>The ASX update</IressText\>
|
|
487
|
+
<IressSkeleton textVariant\="body" width\="50%" />
|
|
488
|
+
</IressStack\>
|
|
489
|
+
</IressCard\>
|
|
490
|
+
</IressCol\>
|
|
491
|
+
<IressCol span\="4"\>
|
|
492
|
+
<IressCard stretch\>
|
|
493
|
+
<IressStack gutter\="md"\>
|
|
494
|
+
<IressSkeleton mode\="rect" height\="300px" />
|
|
495
|
+
<IressText element\="h3"\>In the news</IressText\>
|
|
496
|
+
<IressSkeleton textVariant\="body" width\="50%" />
|
|
497
|
+
</IressStack\>
|
|
498
|
+
</IressCard\>
|
|
499
|
+
</IressCol\>
|
|
500
|
+
</IressRow\>
|
|
501
|
+
</IressStack\>
|
|
502
|
+
</IressContainer\>,
|
|
503
|
+
);
|
|
504
|
+
}, 3000);
|
|
505
|
+
}),
|
|
506
|
+
};
|
|
507
|
+
export const LoadingDashboard \= () \=> {
|
|
508
|
+
const \[critical, setCritical\] \= useState<ReactNode | undefined\>();
|
|
509
|
+
useEffect(() \=> {
|
|
510
|
+
const initialise \= async () \=> {
|
|
511
|
+
setCritical(await API.criticalContent());
|
|
512
|
+
};
|
|
513
|
+
void initialise();
|
|
514
|
+
}, \[\]);
|
|
515
|
+
return (
|
|
516
|
+
<IressLoading pattern\="page" critical\={critical} template\="dashboard" />
|
|
517
|
+
);
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
Copy
|
|
521
|
+
|
|
522
|
+
### [](#start-up)`start-up`
|
|
523
|
+
|
|
524
|
+
The `start-up` loading pattern is used to indicate that the application is loading. It is typically used when the application is first launched. This pattern is used when the application is first launched or when switching from a different application to a new application. It is also used when switching from a client's website to an Iress application or switching themes.
|
|
525
|
+
|
|
526
|
+
#### [](#behavior-4)Behavior
|
|
527
|
+
|
|
528
|
+
1. When `loaded` is false, a progress bar will be displayed after 500ms (configured using `timeout.progress`). This progress bar can be customised using the `renderProgress` prop.
|
|
529
|
+
2. When `loaded` is false after 2.5 seconds (configured using `timeout.message`), the message will be displayed. This message can be customised using the `children` or `messageList` prop.
|
|
530
|
+
3. If using `messageList`, the messages will rotate until the `loaded` prop is set to true.
|
|
531
|
+
4. When `loaded` is true, the progress bar and message will begin fading out. To see the fade out, you will need to use the `IressLoading.shouldRender` hook.
|
|
532
|
+
|
|
533
|
+
#### [](#adjusting-the-progress-bar-1)Adjusting the progress bar
|
|
534
|
+
|
|
535
|
+
The `start-up` loading pattern uses a progress bar to indicate that the application is loading alongside an `estimatedFinishTime` prop. This prop is used to indicate the estimated time until the application is fully loaded, and is used to help the user understand how long they will need to wait and assure them something is happening. The progress bar will animate based on the estimated time.
|
|
536
|
+
|
|
537
|
+
If your application is capable of calculating real progress, you can pass the `progress` prop to the `IressLoading` component and that value will be used instead.
|
|
538
|
+
|
|
539
|
+
Once the `loaded` prop is set to true, the progress bar will always be set to 100% and the loading pattern will fade out.
|
|
540
|
+
|
|
541
|
+
#### [](#rotating-messages)Rotating messages
|
|
542
|
+
|
|
543
|
+
The start-up process is often used initialise the application and load any necessary data. This can include loading user preferences, settings, and any other data that is required to make using the application quicker and easier, however this may add burden to the loading time.
|
|
544
|
+
|
|
545
|
+
To compensate for this, you can pass multiple messages to the pattern using the `messageList` prop. The `messageList` accepts an object map where the key is the time you want the message to start displaying (in milliseconsds) and the value is the message to display. The messages will rotate until the `loaded` prop is set to true.
|
|
546
|
+
|
|
547
|
+
* * *
|
|
548
|
+
|
|
549
|
+
Beta
|
|
550
|
+
|
|
551
|
+
New component
|
|
552
|
+
|
|
553
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
554
|
+
|
|
555
|
+
Hide codeRefresh
|
|
556
|
+
|
|
557
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
558
|
+
|
|
559
|
+
<IressLoading
|
|
560
|
+
messageList\={{
|
|
561
|
+
'0': <IressText mode\="muted"\>Switching applications...</IressText\>,
|
|
562
|
+
'4500': <IressText mode\="muted"\>This is taking longer than expected...</IressText\>
|
|
563
|
+
}}
|
|
564
|
+
pattern\="start-up"
|
|
565
|
+
/>
|
|
566
|
+
|
|
567
|
+
Copy
|
|
568
|
+
|
|
569
|
+
### [](#validate)`validate`
|
|
570
|
+
|
|
571
|
+
The `validate` loading pattern is used to indicate that a server-side validation is in progress. It is typically used when the user is submitting a form or performing an action that requires validation and the user is not expected to leave the page.
|
|
572
|
+
|
|
573
|
+
#### [](#behavior-5)Behavior
|
|
574
|
+
|
|
575
|
+
1. When `loading` is false, the button will be displayed immediately (customised using the `renderButton` prop, or the `children` prop if you do not mind passing in the `loading` prop twice).
|
|
576
|
+
2. When `loading` is true, the button will be disabled and a spinner will be displayed.
|
|
577
|
+
3. When `loading` is true after 2.5 seconds (configured using `timeout`), the message will be displayed. This message can be customised using the `message` prop. Its placement can be adjusted using the `position` prop.
|
|
578
|
+
|
|
579
|
+
#### [](#message-position)Message position
|
|
580
|
+
|
|
581
|
+
Forms come in all shapes and sizes, and the `IressLoading` component is designed to be flexible enough to work with any form. The `position` prop allows you to adjust the placement of the loading message. The available options are:
|
|
582
|
+
|
|
583
|
+
* `top`: The message will be displayed above the button. It is absolute positioned to the top of the button, and will not disrupt the layout of the form.
|
|
584
|
+
* `bottom` (default): The message will be displayed below the button. It is absolute positioned to the bottom of the button, and will not disrupt the layout of the form.
|
|
585
|
+
* `right`: The message will be displayed on the right of the button. It is inline, and will push any content to the right of the button down.
|
|
586
|
+
|
|
587
|
+
* * *
|
|
588
|
+
|
|
589
|
+
Beta
|
|
590
|
+
|
|
591
|
+
New component
|
|
592
|
+
|
|
593
|
+
This component is new, please provide feedback to the IDS team if you encounter any issues.
|
|
594
|
+
|
|
595
|
+
Submit
|
|
596
|
+
|
|
597
|
+
This is taking longer than expected...
|
|
598
|
+
|
|
599
|
+
Hide codeRefresh
|
|
600
|
+
|
|
601
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
602
|
+
|
|
603
|
+
<IressLoading
|
|
604
|
+
loading
|
|
605
|
+
pattern\="validate"
|
|
606
|
+
/>
|
|
607
|
+
|
|
608
|
+
Copy
|
|
609
|
+
|
|
610
|
+
[](#suspense)Suspense
|
|
611
|
+
---------------------
|
|
612
|
+
|
|
613
|
+
Since React 18, React has introduced a new way to handle loading states using `Suspense`, allowing you to lazy load components in an efficient manner.
|
|
614
|
+
|
|
615
|
+
The `IressLoadingSuspense` component is a wrapper around the `IressLoading` component that uses `Suspense` to handle loading states. It is used in the same way as the `IressLoading` component, however you do not need to pass the `loaded` prop or use the `IressLoading.shouldRender` hook. The `IressLoadingSuspense` component will automatically handle the loading state for you.
|
|
616
|
+
|
|
617
|
+
The wizard example can be translated to use `IressLoadingSuspense` as follows (it includes the slow and fast examples).
|
|
618
|
+
|
|
619
|
+
**Differences in behaviour**
|
|
620
|
+
|
|
621
|
+
* The `IressLoadingSuspense` component will automatically handle the loading state for you, so you do not need to pass the `loaded` prop or use the `IressLoading.shouldRender` hook.
|
|
622
|
+
* Nested suspense components will be handled by the highest `IressLoadingSuspense` component. This means that if you have multiple nested `IressLoadingSuspense` components, only the top most one will display a loading state. You can see this in the example when you click the Next button, you no longer see the component loading pattern due to it being nested under the page loading pattern.
|
|
623
|
+
|
|
624
|
+
Hide codeRefresh
|
|
625
|
+
|
|
626
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
627
|
+
|
|
628
|
+
interface PageProps {
|
|
629
|
+
setPage: (page: number) \=> void;
|
|
630
|
+
}
|
|
631
|
+
interface ChartProps {
|
|
632
|
+
money: number | null;
|
|
633
|
+
}
|
|
634
|
+
const API \= {
|
|
635
|
+
getHomePage: async () \=> {
|
|
636
|
+
await new Promise((resolve) \=> {
|
|
637
|
+
setTimeout(resolve, 3000);
|
|
638
|
+
});
|
|
639
|
+
return 1;
|
|
640
|
+
},
|
|
641
|
+
getRetirementIncomeProjection: async () \=> {
|
|
642
|
+
await new Promise((resolve) \=> {
|
|
643
|
+
setTimeout(resolve, 2000);
|
|
644
|
+
});
|
|
645
|
+
return true;
|
|
646
|
+
},
|
|
647
|
+
getChart: async () \=> {
|
|
648
|
+
await new Promise((resolve) \=> {
|
|
649
|
+
const chartImage \= new Image();
|
|
650
|
+
chartImage.src \= retirementGraph;
|
|
651
|
+
setTimeout(resolve, 1000);
|
|
652
|
+
});
|
|
653
|
+
return true;
|
|
654
|
+
},
|
|
655
|
+
chartUpdate: async () \=>
|
|
656
|
+
new Promise<boolean\>((resolve) \=> {
|
|
657
|
+
// Simulate a slow network request.
|
|
658
|
+
setTimeout(() \=> {
|
|
659
|
+
resolve(true);
|
|
660
|
+
}, 2000);
|
|
661
|
+
}),
|
|
662
|
+
};
|
|
663
|
+
const Graph \= () \=> (
|
|
664
|
+
<img
|
|
665
|
+
src\={retirementGraph}
|
|
666
|
+
alt\=""
|
|
667
|
+
style\={{ maxWidth: '100%', height: 'auto' }}
|
|
668
|
+
/>
|
|
669
|
+
);
|
|
670
|
+
const Chart \= () \=> {
|
|
671
|
+
const initialChart \= IressLoadingSuspense.use(API.getChart);
|
|
672
|
+
const \[updatedChart, setUpdatedChart\] \= useState<boolean | undefined\>();
|
|
673
|
+
const \[money, setMoney\] \= useState<number | null\>(null);
|
|
674
|
+
const \[updating, setUpdating\] \= useState(false);
|
|
675
|
+
const deferredMoney \= useDeferredValue(money);
|
|
676
|
+
const chart \= updatedChart ?? initialChart;
|
|
677
|
+
useEffect(() \=> {
|
|
678
|
+
if (deferredMoney \=== null) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
setUpdating(() \=> true);
|
|
682
|
+
const update \= async () \=> {
|
|
683
|
+
const newChart \= await API.chartUpdate();
|
|
684
|
+
setUpdatedChart(newChart);
|
|
685
|
+
setUpdating(() \=> false);
|
|
686
|
+
};
|
|
687
|
+
void update();
|
|
688
|
+
}, \[deferredMoney\]);
|
|
689
|
+
return (
|
|
690
|
+
<IressLoadingSuspense pattern\="component" update\={updating}\>
|
|
691
|
+
{chart && <Graph />}
|
|
692
|
+
<IressPanel\>
|
|
693
|
+
<IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
|
|
694
|
+
> <IressStack gutter\="md"\>
|
|
695
|
+
<h3\>Update projection</h3\>
|
|
696
|
+
<IressFormField
|
|
697
|
+
name\="money"
|
|
698
|
+
label\="My money"
|
|
699
|
+
render\={(controlledProps) \=> (
|
|
700
|
+
<IressInputCurrency {...controlledProps} />
|
|
701
|
+
)}
|
|
702
|
+
/>
|
|
703
|
+
<IressButton type\="submit"\>Update projection</IressButton\>
|
|
704
|
+
</IressStack\>
|
|
705
|
+
</IressForm\>
|
|
706
|
+
</IressPanel\>
|
|
707
|
+
</IressLoadingSuspense\>
|
|
708
|
+
);
|
|
709
|
+
};
|
|
710
|
+
const StartPage \= ({ setPage }: PageProps) \=> (
|
|
711
|
+
<IressText\>
|
|
712
|
+
<h2\>Maximise your retirement</h2\>
|
|
713
|
+
<p\>
|
|
714
|
+
Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
|
|
715
|
+
<hr />
|
|
716
|
+
<IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
|
|
717
|
+
</IressText\>
|
|
718
|
+
);
|
|
719
|
+
const RetirementIncomeProjectionPage \= () \=> {
|
|
720
|
+
const promise \= API.getRetirementIncomeProjection;
|
|
721
|
+
IressLoadingSuspense.use(promise);
|
|
722
|
+
IressLoadingSuspense.uncache(promise);
|
|
723
|
+
return (
|
|
724
|
+
<IressText\>
|
|
725
|
+
<h2\>Retirement Income Projection</h2\>
|
|
726
|
+
<p\>
|
|
727
|
+
We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
|
|
728
|
+
<Chart />
|
|
729
|
+
</IressText\>
|
|
730
|
+
);
|
|
731
|
+
};
|
|
732
|
+
const HomePage \= () \=> {
|
|
733
|
+
const promise \= API.getHomePage;
|
|
734
|
+
const startPage \= IressLoadingSuspense.use(promise);
|
|
735
|
+
IressLoadingSuspense.uncache(promise);
|
|
736
|
+
const \[movedPage, setMovedPage\] \= useState<number | undefined\>();
|
|
737
|
+
const page \= movedPage ?? startPage;
|
|
738
|
+
return (
|
|
739
|
+
<IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
|
|
740
|
+
{page \=== 1 && (
|
|
741
|
+
<IressLoadingSuspense pattern\="page" template\="form"\>
|
|
742
|
+
{page \=== 1 && <StartPage setPage\={setMovedPage} />}
|
|
743
|
+
</IressLoadingSuspense\>
|
|
744
|
+
)}
|
|
745
|
+
{page \=== 2 && (
|
|
746
|
+
<IressLoadingSuspense pattern\="page" template\="form"\>
|
|
747
|
+
<RetirementIncomeProjectionPage />
|
|
748
|
+
</IressLoadingSuspense\>
|
|
749
|
+
)}
|
|
750
|
+
</IressContainer\>
|
|
751
|
+
);
|
|
752
|
+
};
|
|
753
|
+
export const LoadingSuspenseWizard \= () \=> (
|
|
754
|
+
<IressLoadingSuspense pattern\="start-up"\>
|
|
755
|
+
<HomePage />
|
|
756
|
+
</IressLoadingSuspense\>
|
|
757
|
+
);
|
|
758
|
+
|
|
759
|
+
Copy
|
|
760
|
+
|
|
761
|
+
Hide codeRefresh
|
|
762
|
+
|
|
763
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
764
|
+
|
|
765
|
+
interface PageProps {
|
|
766
|
+
setPage: (page: number) \=> void;
|
|
767
|
+
}
|
|
768
|
+
interface ChartProps {
|
|
769
|
+
money: number | null;
|
|
770
|
+
}
|
|
771
|
+
const API \= {
|
|
772
|
+
getHomePage: async () \=> {
|
|
773
|
+
await new Promise((resolve) \=> {
|
|
774
|
+
setTimeout(resolve, 500);
|
|
775
|
+
});
|
|
776
|
+
return 1;
|
|
777
|
+
},
|
|
778
|
+
getRetirementIncomeProjection: async () \=> {
|
|
779
|
+
await new Promise((resolve) \=> {
|
|
780
|
+
setTimeout(resolve, 200);
|
|
781
|
+
});
|
|
782
|
+
return true;
|
|
783
|
+
},
|
|
784
|
+
getChart: async () \=> {
|
|
785
|
+
await new Promise((resolve) \=> {
|
|
786
|
+
const chartImage \= new Image();
|
|
787
|
+
chartImage.onload \= resolve;
|
|
788
|
+
chartImage.src \= retirementGraph;
|
|
789
|
+
});
|
|
790
|
+
return true;
|
|
791
|
+
},
|
|
792
|
+
chartUpdate: async () \=>
|
|
793
|
+
new Promise<boolean\>((resolve) \=> {
|
|
794
|
+
setTimeout(() \=> {
|
|
795
|
+
resolve(true);
|
|
796
|
+
}, 200);
|
|
797
|
+
}),
|
|
798
|
+
};
|
|
799
|
+
const Graph \= () \=> (
|
|
800
|
+
<img
|
|
801
|
+
src\={retirementGraph}
|
|
802
|
+
alt\=""
|
|
803
|
+
style\={{ maxWidth: '100%', height: 'auto' }}
|
|
804
|
+
/>
|
|
805
|
+
);
|
|
806
|
+
const Chart \= () \=> {
|
|
807
|
+
const initialChart \= IressLoadingSuspense.use(API.getChart);
|
|
808
|
+
const \[updatedChart, setUpdatedChart\] \= useState<boolean | undefined\>();
|
|
809
|
+
const \[money, setMoney\] \= useState<number | null\>(null);
|
|
810
|
+
const \[updating, setUpdating\] \= useState(false);
|
|
811
|
+
const deferredMoney \= useDeferredValue(money);
|
|
812
|
+
const chart \= updatedChart ?? initialChart;
|
|
813
|
+
useEffect(() \=> {
|
|
814
|
+
if (deferredMoney \=== null) {
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
setUpdating(() \=> true);
|
|
818
|
+
const update \= async () \=> {
|
|
819
|
+
const newChart \= await API.chartUpdate();
|
|
820
|
+
setUpdatedChart(newChart);
|
|
821
|
+
setUpdating(() \=> false);
|
|
822
|
+
};
|
|
823
|
+
void update();
|
|
824
|
+
}, \[deferredMoney\]);
|
|
825
|
+
return (
|
|
826
|
+
<IressLoadingSuspense pattern\="component" update\={updating}\>
|
|
827
|
+
{chart && <Graph />}
|
|
828
|
+
<IressPanel\>
|
|
829
|
+
<IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
|
|
830
|
+
> <IressStack gutter\="md"\>
|
|
831
|
+
<h3\>Update projection</h3\>
|
|
832
|
+
<IressFormField
|
|
833
|
+
name\="money"
|
|
834
|
+
label\="My money"
|
|
835
|
+
render\={(controlledProps) \=> (
|
|
836
|
+
<IressInputCurrency {...controlledProps} />
|
|
837
|
+
)}
|
|
838
|
+
/>
|
|
839
|
+
<IressButton type\="submit"\>Update projection</IressButton\>
|
|
840
|
+
</IressStack\>
|
|
841
|
+
</IressForm\>
|
|
842
|
+
</IressPanel\>
|
|
843
|
+
</IressLoadingSuspense\>
|
|
844
|
+
);
|
|
845
|
+
};
|
|
846
|
+
const StartPage \= ({ setPage }: PageProps) \=> (
|
|
847
|
+
<IressText\>
|
|
848
|
+
<h2\>Maximise your retirement</h2\>
|
|
849
|
+
<p\>
|
|
850
|
+
Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
|
|
851
|
+
<hr />
|
|
852
|
+
<IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
|
|
853
|
+
</IressText\>
|
|
854
|
+
);
|
|
855
|
+
const RetirementIncomeProjectionPage \= () \=> {
|
|
856
|
+
IressLoadingSuspense.use(API.getRetirementIncomeProjection);
|
|
857
|
+
return (
|
|
858
|
+
<IressText\>
|
|
859
|
+
<h2\>Retirement Income Projection</h2\>
|
|
860
|
+
<p\>
|
|
861
|
+
We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
|
|
862
|
+
<Chart />
|
|
863
|
+
</IressText\>
|
|
864
|
+
);
|
|
865
|
+
};
|
|
866
|
+
const HomePage \= () \=> {
|
|
867
|
+
const startPage \= IressLoadingSuspense.use(API.getHomePage);
|
|
868
|
+
const \[movedPage, setMovedPage\] \= useState<number | undefined\>();
|
|
869
|
+
const page \= movedPage ?? startPage;
|
|
870
|
+
return (
|
|
871
|
+
<IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
|
|
872
|
+
{page \=== 1 && (
|
|
873
|
+
<IressLoadingSuspense pattern\="page" template\="form"\>
|
|
874
|
+
{page \=== 1 && <StartPage setPage\={setMovedPage} />}
|
|
875
|
+
</IressLoadingSuspense\>
|
|
876
|
+
)}
|
|
877
|
+
{page \=== 2 && (
|
|
878
|
+
<IressLoadingSuspense pattern\="page" template\="form"\>
|
|
879
|
+
<RetirementIncomeProjectionPage />
|
|
880
|
+
</IressLoadingSuspense\>
|
|
881
|
+
)}
|
|
882
|
+
</IressContainer\>
|
|
883
|
+
);
|
|
884
|
+
};
|
|
885
|
+
export const LoadingSuspenseWizardFast \= () \=> (
|
|
886
|
+
<IressLoadingSuspense pattern\="start-up"\>
|
|
887
|
+
<HomePage />
|
|
888
|
+
</IressLoadingSuspense\>
|
|
889
|
+
);
|
|
890
|
+
|
|
891
|
+
Copy
|
|
892
|
+
|
|
893
|
+
[](#hooks)Hooks
|
|
894
|
+
---------------
|
|
895
|
+
|
|
896
|
+
### [](#iressloadingshouldrender)`IressLoading.shouldRender`
|
|
897
|
+
|
|
898
|
+
The `IressLoading.shouldRender` hook is used to determine whether the loading pattern should be displayed or not. It is used to control the visibility of the loading pattern based on the `loaded` prop.
|
|
899
|
+
|
|
900
|
+
Its main function is to delay the un-mounting of the loading pattern when the `loaded` prop is set to true to allow for a fade out animation.
|
|
901
|
+
|
|
902
|
+
\[data-radix-scroll-area-viewport\] {
|
|
903
|
+
scrollbar-width: none;
|
|
904
|
+
-ms-overflow-style: none;
|
|
905
|
+
-webkit-overflow-scrolling: touch;
|
|
906
|
+
}
|
|
907
|
+
\[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
|
|
908
|
+
display: none;
|
|
909
|
+
}
|
|
910
|
+
:where(\[data-radix-scroll-area-viewport\]) {
|
|
911
|
+
display: flex;
|
|
912
|
+
flex-direction: column;
|
|
913
|
+
align-items: stretch;
|
|
914
|
+
}
|
|
915
|
+
:where(\[data-radix-scroll-area-content\]) {
|
|
916
|
+
flex-grow: 1;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
const \[loaded, setLoaded\] \= useState(false);
|
|
920
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
921
|
+
// Use renderLoading instead of !loaded for the smooth transition.
|
|
922
|
+
if (renderLoading) return <IressLoading pattern\="page" loaded\={loaded} />;
|
|
923
|
+
else return <IressText\>Content is loaded</IressText\>;
|
|
924
|
+
|
|
925
|
+
Copy
|
|
926
|
+
|
|
927
|
+
### [](#iressloadingsuspenseuse)`IressLoadingSuspense.use`
|
|
928
|
+
|
|
929
|
+
The `IressLoadingSuspense.use` hook is a polyfill for the React 19 `use` hook, allowing you to have similar functionality in React 18. It is used to handle loading states when using `IressLoadingSuspense`.
|
|
930
|
+
|
|
931
|
+
It is not as smart as the `use` hook in React 19, it will cache the result of the promise and will not re-fetch the data if the component is re-mounted. You can clear a function's results in the cache by using the `IressLoadingSuspense.uncache` function.
|
|
932
|
+
|
|
933
|
+
Avoid in React 19
|
|
934
|
+
-----------------
|
|
935
|
+
|
|
936
|
+
If you are using React 19, it is recommended to use the built-in `use` hook instead of this one. In future releases, this hook will be deprecated and removed from the library.
|
|
937
|
+
|
|
938
|
+
\[data-radix-scroll-area-viewport\] {
|
|
939
|
+
scrollbar-width: none;
|
|
940
|
+
-ms-overflow-style: none;
|
|
941
|
+
-webkit-overflow-scrolling: touch;
|
|
942
|
+
}
|
|
943
|
+
\[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
|
|
944
|
+
display: none;
|
|
945
|
+
}
|
|
946
|
+
:where(\[data-radix-scroll-area-viewport\]) {
|
|
947
|
+
display: flex;
|
|
948
|
+
flex-direction: column;
|
|
949
|
+
align-items: stretch;
|
|
950
|
+
}
|
|
951
|
+
:where(\[data-radix-scroll-area-content\]) {
|
|
952
|
+
flex-grow: 1;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
const HomePage \= () \=> {
|
|
956
|
+
const pageData \= IressLoadingSuspense.use(API.fetchPage('home'));
|
|
957
|
+
return (
|
|
958
|
+
<IressText\>
|
|
959
|
+
<h2\>{pageData.title}</h2\>
|
|
960
|
+
<p\>{pageData.description}</p\>
|
|
961
|
+
</IressText\>
|
|
962
|
+
);
|
|
963
|
+
};
|
|
964
|
+
export const App \= () \=> (
|
|
965
|
+
<IressLoadingSuspense pattern\="start-up"\>
|
|
966
|
+
<HomePage />
|
|
967
|
+
</IressLoadingSuspense\>
|
|
968
|
+
);
|
|
969
|
+
|
|
970
|
+
Copy
|
|
971
|
+
|
|
972
|
+
[](#examples)Examples
|
|
973
|
+
---------------------
|
|
974
|
+
|
|
975
|
+
Below are some examples of how to use the `IressLoading` component in different scenarios.
|
|
976
|
+
|
|
977
|
+
### [](#wizard)Wizard
|
|
978
|
+
|
|
979
|
+
Here you can see how a wizard can use the `IressLoading` component at different stages of the application. The first example shows a `slow` wizard, and the second example shows how the same code looks when the requests are fast. The main difference is you see minimal loading inidicators in the second example, improving the perception that the system is fast.
|
|
980
|
+
|
|
981
|
+
Hide codeRefresh
|
|
982
|
+
|
|
983
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
984
|
+
|
|
985
|
+
interface PageProps {
|
|
986
|
+
setPage: (page: number) \=> void;
|
|
987
|
+
}
|
|
988
|
+
interface ChartProps {
|
|
989
|
+
money: number | null;
|
|
990
|
+
}
|
|
991
|
+
const API \= {
|
|
992
|
+
initialise: async () \=>
|
|
993
|
+
new Promise<boolean\>((resolve) \=> {
|
|
994
|
+
// Simulate a slow network request.
|
|
995
|
+
setTimeout(() \=> {
|
|
996
|
+
resolve(true);
|
|
997
|
+
}, 3000);
|
|
998
|
+
}),
|
|
999
|
+
data: async () \=>
|
|
1000
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1001
|
+
// Simulate a slow network request.
|
|
1002
|
+
setTimeout(() \=> {
|
|
1003
|
+
resolve(true);
|
|
1004
|
+
}, 2000);
|
|
1005
|
+
}),
|
|
1006
|
+
chart: async () \=>
|
|
1007
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1008
|
+
// Simulate a slow network request.
|
|
1009
|
+
setTimeout(() \=> {
|
|
1010
|
+
resolve(true);
|
|
1011
|
+
}, 2000);
|
|
1012
|
+
}),
|
|
1013
|
+
chartUpdate: async () \=>
|
|
1014
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1015
|
+
// Simulate a slow network request.
|
|
1016
|
+
setTimeout(() \=> {
|
|
1017
|
+
resolve(true);
|
|
1018
|
+
}, 2000);
|
|
1019
|
+
}),
|
|
1020
|
+
};
|
|
1021
|
+
const Graph \= () \=> (
|
|
1022
|
+
<img
|
|
1023
|
+
src\={retirementGraph}
|
|
1024
|
+
alt\=""
|
|
1025
|
+
style\={{ maxWidth: '100%', height: 'auto' }}
|
|
1026
|
+
/>
|
|
1027
|
+
);
|
|
1028
|
+
const Chart \= () \=> {
|
|
1029
|
+
const \[chart, setChart\] \= useState(false);
|
|
1030
|
+
const \[money, setMoney\] \= useState<number | null\>(null);
|
|
1031
|
+
const \[loaded, setLoaded\] \= useState(false);
|
|
1032
|
+
const \[updating, setUpdating\] \= useState(false);
|
|
1033
|
+
const safeLoaded \= IressLoading.shouldRender(loaded);
|
|
1034
|
+
const deferredMoney \= useDeferredValue(money);
|
|
1035
|
+
useEffect(() \=> {
|
|
1036
|
+
const initialise \= async () \=> {
|
|
1037
|
+
const newChart \= await API.chart();
|
|
1038
|
+
setChart(newChart);
|
|
1039
|
+
setLoaded(() \=> true);
|
|
1040
|
+
};
|
|
1041
|
+
void initialise();
|
|
1042
|
+
}, \[\]);
|
|
1043
|
+
useEffect(() \=> {
|
|
1044
|
+
if (deferredMoney \=== null) {
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
setUpdating(() \=> true);
|
|
1048
|
+
const update \= async () \=> {
|
|
1049
|
+
const newChart \= await API.chartUpdate();
|
|
1050
|
+
setChart(newChart);
|
|
1051
|
+
setUpdating(() \=> false);
|
|
1052
|
+
};
|
|
1053
|
+
void update();
|
|
1054
|
+
}, \[deferredMoney\]);
|
|
1055
|
+
return (
|
|
1056
|
+
<IressLoading pattern\="component" loaded\={!safeLoaded} update\={updating}\>
|
|
1057
|
+
{chart && <Graph />}
|
|
1058
|
+
<IressPanel\>
|
|
1059
|
+
<IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
|
|
1060
|
+
> <IressStack gutter\="md"\>
|
|
1061
|
+
<h3\>Update projection</h3\>
|
|
1062
|
+
<IressFormField
|
|
1063
|
+
name\="money"
|
|
1064
|
+
label\="My money"
|
|
1065
|
+
render\={(controlledProps) \=> (
|
|
1066
|
+
<IressInputCurrency {...controlledProps} />
|
|
1067
|
+
)}
|
|
1068
|
+
/>
|
|
1069
|
+
<IressButton type\="submit"\>Update projection</IressButton\>
|
|
1070
|
+
</IressStack\>
|
|
1071
|
+
</IressForm\>
|
|
1072
|
+
</IressPanel\>
|
|
1073
|
+
</IressLoading\>
|
|
1074
|
+
);
|
|
1075
|
+
};
|
|
1076
|
+
const StartPage \= ({ setPage }: PageProps) \=> (
|
|
1077
|
+
<IressText\>
|
|
1078
|
+
<h2\>Maximise your retirement</h2\>
|
|
1079
|
+
<p\>
|
|
1080
|
+
Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
|
|
1081
|
+
<hr />
|
|
1082
|
+
<IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
|
|
1083
|
+
</IressText\>
|
|
1084
|
+
);
|
|
1085
|
+
const RetirementIncomeProjectionPage \= () \=> {
|
|
1086
|
+
const \[data, setData\] \= useState(false);
|
|
1087
|
+
const loaded \= data !== false;
|
|
1088
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
1089
|
+
useEffect(() \=> {
|
|
1090
|
+
const initialise \= async () \=> {
|
|
1091
|
+
const newData \= await API.data();
|
|
1092
|
+
setData(newData);
|
|
1093
|
+
};
|
|
1094
|
+
void initialise();
|
|
1095
|
+
}, \[\]);
|
|
1096
|
+
if (renderLoading) {
|
|
1097
|
+
return <IressLoading pattern\="page" template\="form" loaded\={loaded} />;
|
|
1098
|
+
}
|
|
1099
|
+
return (
|
|
1100
|
+
<IressText\>
|
|
1101
|
+
<h2\>Retirement Income Projection</h2\>
|
|
1102
|
+
<p\>
|
|
1103
|
+
We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
|
|
1104
|
+
<Chart />
|
|
1105
|
+
</IressText\>
|
|
1106
|
+
);
|
|
1107
|
+
};
|
|
1108
|
+
export const LoadingWizard \= () \=> {
|
|
1109
|
+
const \[page, setPage\] \= useState(0);
|
|
1110
|
+
const loaded \= page \> 0;
|
|
1111
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
1112
|
+
useEffect(() \=> {
|
|
1113
|
+
const initialise \= async () \=> {
|
|
1114
|
+
await API.initialise();
|
|
1115
|
+
setPage(1);
|
|
1116
|
+
};
|
|
1117
|
+
void initialise();
|
|
1118
|
+
}, \[\]);
|
|
1119
|
+
if (renderLoading) {
|
|
1120
|
+
return <IressLoading pattern\="start-up" loaded\={loaded} />;
|
|
1121
|
+
}
|
|
1122
|
+
return (
|
|
1123
|
+
<IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
|
|
1124
|
+
{page \=== 1 && <StartPage setPage\={setPage} />}
|
|
1125
|
+
{page \=== 2 && <RetirementIncomeProjectionPage />}
|
|
1126
|
+
</IressContainer\>
|
|
1127
|
+
);
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
Copy
|
|
1131
|
+
|
|
1132
|
+
Hide codeRefresh
|
|
1133
|
+
|
|
1134
|
+
\[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
|
|
1135
|
+
|
|
1136
|
+
interface PageProps {
|
|
1137
|
+
setPage: (page: number) \=> void;
|
|
1138
|
+
}
|
|
1139
|
+
interface ChartProps {
|
|
1140
|
+
money: number | null;
|
|
1141
|
+
}
|
|
1142
|
+
const API \= {
|
|
1143
|
+
initialise: async () \=>
|
|
1144
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1145
|
+
// Simulate a fast network request.
|
|
1146
|
+
setTimeout(() \=> {
|
|
1147
|
+
resolve(true);
|
|
1148
|
+
}, 300);
|
|
1149
|
+
}),
|
|
1150
|
+
data: async () \=>
|
|
1151
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1152
|
+
// Simulate a fast network request.
|
|
1153
|
+
setTimeout(() \=> {
|
|
1154
|
+
resolve(true);
|
|
1155
|
+
}, 300);
|
|
1156
|
+
}),
|
|
1157
|
+
chart: async () \=>
|
|
1158
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1159
|
+
// Simulate a fast network request.
|
|
1160
|
+
setTimeout(() \=> {
|
|
1161
|
+
resolve(true);
|
|
1162
|
+
}, 300);
|
|
1163
|
+
}),
|
|
1164
|
+
chartUpdate: async () \=>
|
|
1165
|
+
new Promise<boolean\>((resolve) \=> {
|
|
1166
|
+
// Simulate a fast network request.
|
|
1167
|
+
setTimeout(() \=> {
|
|
1168
|
+
resolve(true);
|
|
1169
|
+
}, 300);
|
|
1170
|
+
}),
|
|
1171
|
+
};
|
|
1172
|
+
const Graph \= () \=> (
|
|
1173
|
+
<img
|
|
1174
|
+
src\={retirementGraph}
|
|
1175
|
+
alt\=""
|
|
1176
|
+
style\={{ maxWidth: '100%', height: 'auto' }}
|
|
1177
|
+
/>
|
|
1178
|
+
);
|
|
1179
|
+
const Chart \= () \=> {
|
|
1180
|
+
const \[chart, setChart\] \= useState(false);
|
|
1181
|
+
const \[money, setMoney\] \= useState<number | null\>(null);
|
|
1182
|
+
const \[loaded, setLoaded\] \= useState(false);
|
|
1183
|
+
const \[updating, setUpdating\] \= useState(false);
|
|
1184
|
+
const safeLoaded \= IressLoading.shouldRender(loaded);
|
|
1185
|
+
const deferredMoney \= useDeferredValue(money);
|
|
1186
|
+
useEffect(() \=> {
|
|
1187
|
+
const initialise \= async () \=> {
|
|
1188
|
+
const newChart \= await API.chart();
|
|
1189
|
+
setChart(newChart);
|
|
1190
|
+
const testImg \= new Image();
|
|
1191
|
+
testImg.onload \= () \=> setLoaded(true);
|
|
1192
|
+
testImg.src \= retirementGraph;
|
|
1193
|
+
};
|
|
1194
|
+
void initialise();
|
|
1195
|
+
}, \[\]);
|
|
1196
|
+
useEffect(() \=> {
|
|
1197
|
+
if (deferredMoney \=== null) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
setUpdating(() \=> true);
|
|
1201
|
+
const update \= async () \=> {
|
|
1202
|
+
const newChart \= await API.chartUpdate();
|
|
1203
|
+
setChart(newChart);
|
|
1204
|
+
setUpdating(() \=> false);
|
|
1205
|
+
};
|
|
1206
|
+
void update();
|
|
1207
|
+
}, \[deferredMoney\]);
|
|
1208
|
+
return (
|
|
1209
|
+
<IressLoading pattern\="component" loaded\={!safeLoaded} update\={updating}\>
|
|
1210
|
+
{chart && <Graph />}
|
|
1211
|
+
<IressPanel\>
|
|
1212
|
+
<IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
|
|
1213
|
+
> <IressStack gutter\="md"\>
|
|
1214
|
+
<h3\>Update projection</h3\>
|
|
1215
|
+
<IressFormField
|
|
1216
|
+
name\="money"
|
|
1217
|
+
label\="My money"
|
|
1218
|
+
render\={(controlledProps) \=> (
|
|
1219
|
+
<IressInputCurrency {...controlledProps} />
|
|
1220
|
+
)}
|
|
1221
|
+
/>
|
|
1222
|
+
<IressButton type\="submit"\>Update projection</IressButton\>
|
|
1223
|
+
</IressStack\>
|
|
1224
|
+
</IressForm\>
|
|
1225
|
+
</IressPanel\>
|
|
1226
|
+
</IressLoading\>
|
|
1227
|
+
);
|
|
1228
|
+
};
|
|
1229
|
+
const StartPage \= ({ setPage }: PageProps) \=> (
|
|
1230
|
+
<IressText\>
|
|
1231
|
+
<h2\>Maximise your retirement</h2\>
|
|
1232
|
+
<p\>
|
|
1233
|
+
Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
|
|
1234
|
+
<hr />
|
|
1235
|
+
<IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
|
|
1236
|
+
</IressText\>
|
|
1237
|
+
);
|
|
1238
|
+
const RetirementIncomeProjectionPage \= () \=> {
|
|
1239
|
+
const \[data, setData\] \= useState(false);
|
|
1240
|
+
const loaded \= data !== false;
|
|
1241
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
1242
|
+
useEffect(() \=> {
|
|
1243
|
+
const initialise \= async () \=> {
|
|
1244
|
+
const newData \= await API.data();
|
|
1245
|
+
setData(newData);
|
|
1246
|
+
};
|
|
1247
|
+
void initialise();
|
|
1248
|
+
}, \[\]);
|
|
1249
|
+
if (renderLoading) {
|
|
1250
|
+
return <IressLoading pattern\="page" template\="form" loaded\={loaded} />;
|
|
1251
|
+
}
|
|
1252
|
+
return (
|
|
1253
|
+
<IressText\>
|
|
1254
|
+
<h2\>Retirement Income Projection</h2\>
|
|
1255
|
+
<p\>
|
|
1256
|
+
We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
|
|
1257
|
+
<Chart />
|
|
1258
|
+
</IressText\>
|
|
1259
|
+
);
|
|
1260
|
+
};
|
|
1261
|
+
export const LoadingWizardFast \= () \=> {
|
|
1262
|
+
const \[page, setPage\] \= useState(0);
|
|
1263
|
+
const loaded \= page \> 0;
|
|
1264
|
+
const renderLoading \= IressLoading.shouldRender(loaded);
|
|
1265
|
+
useEffect(() \=> {
|
|
1266
|
+
const initialise \= async () \=> {
|
|
1267
|
+
await API.initialise();
|
|
1268
|
+
setPage(1);
|
|
1269
|
+
};
|
|
1270
|
+
void initialise();
|
|
1271
|
+
}, \[\]);
|
|
1272
|
+
if (renderLoading) {
|
|
1273
|
+
return <IressLoading pattern\="start-up" loaded\={loaded} />;
|
|
1274
|
+
}
|
|
1275
|
+
return (
|
|
1276
|
+
<IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
|
|
1277
|
+
{page \=== 1 && <StartPage setPage\={setPage} />}
|
|
1278
|
+
{page \=== 2 && <RetirementIncomeProjectionPage />}
|
|
1279
|
+
</IressContainer\>
|
|
1280
|
+
);
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
Copy
|
|
1284
|
+
|
|
1285
|
+
On this page
|
|
1286
|
+
|
|
1287
|
+
* [Overview](#overview)
|
|
1288
|
+
* [Props](#props)
|
|
1289
|
+
* [Usage](#usage)
|
|
1290
|
+
* [Be consistent](#be-consistent)
|
|
1291
|
+
* [Behaviour](#behaviour)
|
|
1292
|
+
* [Patterns](#patterns)
|
|
1293
|
+
* [component](#component)
|
|
1294
|
+
* [default](#default)
|
|
1295
|
+
* [long](#long)
|
|
1296
|
+
* [page](#page)
|
|
1297
|
+
* [start-up](#start-up)
|
|
1298
|
+
* [validate](#validate)
|
|
1299
|
+
* [Suspense](#suspense)
|
|
1300
|
+
* [Hooks](#hooks)
|
|
1301
|
+
* [IressLoading.shouldRender](#iressloadingshouldrender)
|
|
1302
|
+
* [IressLoadingSuspense.use](#iressloadingsuspenseuse)
|
|
1303
|
+
* [Examples](#examples)
|
|
1304
|
+
* [Wizard](#wizard)
|