oneslash-design-system 2.14.2 → 2.15.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.
Files changed (52) hide show
  1. package/README.md +10 -0
  2. package/dist/DESIGN.md +134 -1
  3. package/dist/cases/agent-asks-before-risky-action.md +29 -0
  4. package/dist/cases/agent-cancels-when-unanswered.md +27 -0
  5. package/dist/cases/agent-refuses-clearly.md +31 -0
  6. package/dist/cases/agent-says-what-it-is.md +29 -0
  7. package/dist/cases/agent-shows-progress.md +30 -0
  8. package/dist/cases/agent-shows-sources.md +26 -0
  9. package/dist/cases/login-page/centered.d.ts +1 -0
  10. package/dist/cases/login-page/centered.jsx +69 -0
  11. package/dist/cases/login-page/email-only.d.ts +1 -0
  12. package/dist/cases/login-page/email-only.jsx +56 -0
  13. package/dist/cases/login-page/provider-first.d.ts +1 -0
  14. package/dist/cases/login-page/provider-first.jsx +63 -0
  15. package/dist/cases/login-page/split.d.ts +1 -0
  16. package/dist/cases/login-page/split.jsx +76 -0
  17. package/dist/cases/login-page.md +356 -0
  18. package/dist/cases.json +256 -0
  19. package/dist/components/brandIcon.d.ts +12 -0
  20. package/dist/components/brandIcon.jsx +24 -0
  21. package/dist/components/form.d.ts +11 -0
  22. package/dist/components/form.jsx +22 -0
  23. package/dist/components/image.d.ts +14 -0
  24. package/dist/components/image.jsx +6 -0
  25. package/dist/components/layout.d.ts +18 -1
  26. package/dist/components/layout.jsx +16 -0
  27. package/dist/components/line.d.ts +3 -1
  28. package/dist/components/line.jsx +8 -1
  29. package/dist/components/tabsContainer.jsx +4 -2
  30. package/dist/components/tooltip.jsx +3 -1
  31. package/dist/designTokens.d.ts +1 -0
  32. package/dist/designTokens.js +1 -0
  33. package/dist/native-mapping.json +17 -1
  34. package/dist/stories/BrandIcon.stories.d.ts +9 -0
  35. package/dist/stories/BrandIcon.stories.jsx +19 -0
  36. package/dist/stories/Cases.generated.stories.d.ts +8 -0
  37. package/dist/stories/Cases.generated.stories.jsx +12 -0
  38. package/dist/stories/Form.stories.d.ts +6 -0
  39. package/dist/stories/Form.stories.jsx +26 -0
  40. package/dist/stories/Image.stories.d.ts +7 -0
  41. package/dist/stories/Image.stories.jsx +18 -0
  42. package/dist/stories/Line.stories.d.ts +1 -0
  43. package/dist/stories/Line.stories.jsx +12 -0
  44. package/dist/stories/PageComponents.stories.d.ts +2 -0
  45. package/dist/stories/PageComponents.stories.jsx +15 -1
  46. package/dist/tailwind-preset-auto.js +2 -1
  47. package/dist/tailwind-preset.js +2 -1
  48. package/dist/theme-auto.css +1 -0
  49. package/dist/theme.css +1 -0
  50. package/dist/tokens.css +1 -0
  51. package/dist/tokens.json +7 -0
  52. package/package.json +4 -2
package/README.md CHANGED
@@ -63,6 +63,16 @@ import SectionIntro from 'oneslash-design-system/components/sectionIntro';
63
63
  </PageShell>
64
64
  ```
65
65
 
66
+ ## Design cases
67
+
68
+ A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has two to four options, each with a line on when to use it and a working example built only from this package. 2.15.0 has the first seven: the login page and six rules for an agent.
69
+
70
+ - `oneslash-design-system/cases.json` lists every case with its rule text, options, Do and Don't lines, and the source of each example.
71
+ - `oneslash-design-system/cases/<id>.md` is one case as text, and `oneslash-design-system/cases/<id>/<option>.jsx` is the example itself.
72
+ - The Cases section of [DESIGN.md](./dist/DESIGN.md) is the same list for an agent to read.
73
+
74
+ The source is `cases/<id>/case.js` plus one `.tsx` file per option. `npm run build` checks each example uses only ODS parts and writes the files above.
75
+
66
76
  ## Releasing
67
77
 
68
78
  Bump `version` in `package.json`, run `npm run build`, and merge to `main`. The Release workflow runs the tests and `npm run check:contrast`, then publishes to npm, creates the tag and GitHub Release with notes from the merged PR titles, and updates the docs site. The same `v<version>` tag is the Swift package version.
package/dist/DESIGN.md CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  ODS is the oneSlash design system. One source, `designTokens.js`, defines every color, spacing step, radius and type role. The build turns it into CSS themes and Tailwind presets for the web, a Swift package for Apple apps, and `tokens.json` in the W3C design tokens format. The tables in this file are generated from the same source, so they match the tokens exactly.
5
5
 
6
+ Before you lay out a page or an agent behaviour, check the Cases section at the end of this file.
7
+
6
8
  ## Using ODS on the web
7
9
 
8
10
  The package ships Tailwind class names, CSS variables and untranspiled `.jsx`. Each app compiles the components itself and picks one theme.
@@ -291,14 +293,17 @@ For each web component, the table gives the native control to use. System contro
291
293
  | --- | --- | --- | --- |
292
294
  | alert | `ODSBanner` for an inline message; `.alert` for one that needs a decision | `OdsBanner` for an inline message; `AlertDialog` for one that needs a decision | ODS has no native toast: on Android use `Snackbar` in a `SnackbarHost`. |
293
295
  | button | `Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary | `Button`, `OutlinedButton` | Tertiary and text-only: `.borderless` / `TextButton`. On Apple, apply `.odsProminentButton()` to every prominent button. Under `odsTheme` the label of a `.borderedProminent` or `.glassProminent` button takes `text.primary`, not the system white, which is below 4.5:1 on the accent in default dark, forest light, forest dark, clay dark, indigo light, indigo dark, wine light, wine dark. In forest light it is the same color as the fill, so the label cannot be seen. The modifier keeps the system style and sets the label to `accent.contrast`. Compose needs nothing: `onPrimary` is `accent.contrast`. |
296
+ | brandIcon | the provider's own button where one exists (`SignInWithAppleButton`), else an asset in the app | an asset in the app | |
294
297
  | checkBox | `Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS) | `Checkbox` | |
295
298
  | emptyBox | `ContentUnavailableView` | `OdsEmptyState` | The system has this control on Apple, so ODS adds no part there. Material has none, so ODS does. |
296
299
  | factsRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `LabeledContent` rows in a `Form` / `ListItem` rows. |
297
300
  | figure | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: an `Image` with a caption `Text` in the caption text style. |
301
+ | form | `Form` | A `Column` of fields; submit from the keyboard action | On Apple the system lays the fields out; do not add spacing. |
298
302
  | heading | `Text` with the type role's text style and `.accessibilityAddTraits(.isHeader)` | `Text` with the type role's `MaterialTheme.typography` style and `Modifier.semantics { heading() }` | |
299
303
  | icon | `Image(systemName:)` (SF Symbols) | Material Symbols | |
300
304
  | iconButton | `Button` with a `Label` and `.labelStyle(.iconOnly)` | `IconButton` | |
301
- | layout | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `VStack` / `HStack` / `Grid`; Compose `Column` / `Row` / `LazyVerticalGrid`. |
305
+ | image | `Image` / `AsyncImage` | `Image` with the app's image loader | |
306
+ | layout | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `VStack` / `HStack` / `Grid`; Compose `Column` / `Row` / `LazyVerticalGrid`. `Center` and `Split` are for web pages; a native screen is already one column. |
302
307
  | line | `Divider` | `HorizontalDivider`, `VerticalDivider` | |
303
308
  | link | `Link` | `Text` with a `LinkAnnotation.Url` in its `AnnotatedString` | |
304
309
  | linkCard | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `NavigationLink` row in a `List` / a clickable `ListItem`. |
@@ -365,3 +370,131 @@ A style is named `<part>.<variant>.<color or state>`. Each piece of it takes one
365
370
  | `tag.contained.success` | `success.fill` | `success.onFill` | `success.fill` | |
366
371
  | `tag.textOnly.success` | | `success.text` | `success.fill` | |
367
372
  | `tag.dot.success` | | `text.primary` | | `success.main` |
373
+
374
+ ## Cases
375
+
376
+ A case answers one design question the way oneSlash does, such as how to lay out a login page or how an agent asks before a risky action. A rule gives one answer and is printed here in full.
377
+
378
+ A design case has a few options, each with a working example. Open the file named in the table for the one you need. In an app, import a component like this: `import Button from 'oneslash-design-system/components/button'`.
379
+
380
+ ### An agent asks before a risky action
381
+
382
+ The agent is about to do something that changes shared work or is hard to undo.
383
+
384
+ Answer: An action is risky when it changes shared work or is hard to undo. In a product that works with code, that includes opening or merging a pull request, deleting files, closing an issue and rolling back a release. Carrying out a plan of several changes is risky too. Before a risky action the agent stops and posts a card with the exact action: every step it will take, or the changes themselves, which the person can open. The agent does nothing until the person presses the approve button.
385
+
386
+ **Not built yet:** In Scindo the agent asks before carrying out a plan, opening a pull request and merging one. It does not yet ask before deleting files, closing an issue or rolling back a release.
387
+
388
+ Why: A person can only approve what they can see, and an agent's mistake in shared work costs other people.
389
+
390
+ Do:
391
+ - List every step in the card, in the order the agent will do them.
392
+ - Offer a way to see the full changes, such as a View Changes button, before the approve button is pressed.
393
+ - Let the person edit the plan or cancel it, not only approve it.
394
+ - Once decided, mark the card Approved or Cancelled and remove its buttons.
395
+
396
+ Don't:
397
+ - Do not carry out a risky action before the person approves it.
398
+ - Do not replace the steps or the changes with a one-line summary.
399
+ - Do not let the agent write the label of an approve or merge button.
400
+ - Do not let a second click on a decided card approve or cancel it again.
401
+
402
+ ### An agent cancels and reports when nobody answers
403
+
404
+ The agent has asked a question or proposed an action, and nobody answers.
405
+
406
+ Answer: The agent never takes silence as a yes: while a question or proposal waits, it does nothing that depends on the answer. Each product sets the waiting time and shows it on the waiting card. When the time is up, the agent cancels the request, marks the card Cancelled, and posts one line saying what it did not do. The agent may write a plan that lists the unanswered questions as open questions. It may not carry out anything that depends on an answer.
407
+
408
+ **Not built yet:** No product cancels a waiting request on its own yet. In Scindo a request waits until a person answers, cancels or skips it, and the waiting time is not decided.
409
+
410
+ Why: An agent that acts on silence does work nobody approved, and one that waits forever leaves work stuck without saying so.
411
+
412
+ Do:
413
+ - Keep the card and its buttons open until someone answers or the request is cancelled.
414
+ - Notify the person who asked when the agent needs their answer.
415
+ - When a request is cancelled, mark the card Cancelled and post one line on what was not done.
416
+ - List questions asked before a plan that nobody answered as open questions in that plan.
417
+
418
+ Don't:
419
+ - Do not treat no answer as approval.
420
+ - Do not cancel a request without saying so in the thread.
421
+
422
+ ### An agent refuses clearly
423
+
424
+ The product will not let the agent answer a request, for example because the workspace used all its agent replies for the month, reached its spending cap, or sent too many requests at once.
425
+
426
+ Answer: The refusal says in one plain sentence which limit was reached, and either who can change it or when to try again. A person who can lift the limit gets the one button that does it, such as Upgrade or Change Budget Cap. When an admin can lift the limit, everyone else is told to ask a workspace admin. A limit that passes with time says when to try again instead.
427
+
428
+ **Not built yet:** Scindo on the web does not follow this yet: it shows the Upgrade button to everyone. Scindo's Apple app shows it only to admins.
429
+
430
+ Why: A person who is refused needs to know why and what to do next, or they will just send the request again.
431
+
432
+ Do:
433
+ - Say which limit was reached, with the number when there is one: 'You've used all 50 AI agent responses this month.'
434
+ - Say who can change it, or when to try again: 'Try again in a minute.'
435
+ - Show the button that lifts the limit only to a person allowed to use it.
436
+ - Let the person close the refusal without acting, with a button such as 'Not Now'.
437
+
438
+ Don't:
439
+ - Do not show a general error message for a refusal.
440
+ - Do not show an Upgrade button to someone who cannot upgrade.
441
+
442
+ ### An agent says what it is
443
+
444
+ The agent posts in a thread where people also write, or replies to a person.
445
+
446
+ Answer: Every agent message has marks no person's message has. It shows an icon avatar instead of a photo, and the agent's own name. When the product knows which model wrote the reply, it shows the model name in small text next to the time. An agent the workspace connects from outside gets a plain bot icon, not the product's logo.
447
+
448
+ Why: People must see at a glance whether a person or an agent wrote what they are reading, and whose agent it is.
449
+
450
+ Do:
451
+ - Show the agent with an icon avatar, never a photo or an initial.
452
+ - Name the agent in the message header: its role or given name, or 'Agent' when it has none.
453
+ - Show the model name next to the time when the product knows it.
454
+ - Show the product's logo on the product's own agent and a plain bot icon on an agent from outside, so people see whose agent it is.
455
+
456
+ Don't:
457
+ - Do not show a photo for an agent, even when one is set.
458
+ - Do not show the product's logo on an agent the product does not run.
459
+
460
+ ### An agent shows its progress
461
+
462
+ The agent is working on a request and its reply is not ready yet.
463
+
464
+ Answer: While it works, the agent shows a live row in the thread, where its reply will appear: its name, the model, the seconds so far, the steps it has finished with a check mark, and the step it is on now in plain words, such as 'Reading file'. A Stop button stays on that row for the whole run. When the run is stopped, the agent posts a short note that it stopped.
465
+
466
+ Why: A person waiting on an agent needs to know it is still working, what it is doing, and that they can stop it.
467
+
468
+ Do:
469
+ - Show the progress row in the thread, where the reply will appear.
470
+ - Name the current step in plain words, such as 'Reading file' or 'Editing code'.
471
+ - Keep finished steps in view, each with a check mark.
472
+ - Keep a Stop button on the row for the whole run.
473
+
474
+ Don't:
475
+ - Do not show a spinner with no words.
476
+ - Do not hide the Stop button while the agent writes its reply.
477
+ - Do not say the agent stopped before the run has really ended.
478
+
479
+ ### An agent shows its sources
480
+
481
+ The agent answers from things it read: documents, files, chat, tasks, or a connected service such as a code host or a design tool.
482
+
483
+ Answer: Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section.
484
+
485
+ Why: A person can check an answer only when they can open what it came from.
486
+
487
+ Do:
488
+ - Put the sources directly under the reply they support.
489
+ - Show each source as a card with its title and where it lives, such as the space name or the date.
490
+ - Make each card open the source itself, in the product or on the service it came from.
491
+ - Show the first six sources and a 'Show N more' button for the rest.
492
+
493
+ Don't:
494
+ - Do not show a sources section when the reply used no sources.
495
+ - Do not show source cards on a person's message.
496
+ - Do not link a source card to any site other than the product or the service the source came from.
497
+
498
+ | Case | When | File |
499
+ | --- | --- | --- |
500
+ | Login page | A person who already has an account opens the product and is not signed in. | cases/login-page.md |
@@ -0,0 +1,29 @@
1
+ # An agent asks before a risky action
2
+
3
+ The agent is about to do something that changes shared work or is hard to undo.
4
+
5
+ ## Answer
6
+
7
+ An action is risky when it changes shared work or is hard to undo. In a product that works with code, that includes opening or merging a pull request, deleting files, closing an issue and rolling back a release. Carrying out a plan of several changes is risky too. Before a risky action the agent stops and posts a card with the exact action: every step it will take, or the changes themselves, which the person can open. The agent does nothing until the person presses the approve button.
8
+
9
+ **Not built yet:** In Scindo the agent asks before carrying out a plan, opening a pull request and merging one. It does not yet ask before deleting files, closing an issue or rolling back a release.
10
+
11
+ ## Why
12
+
13
+ A person can only approve what they can see, and an agent's mistake in shared work costs other people.
14
+
15
+ ## Do
16
+
17
+ - List every step in the card, in the order the agent will do them.
18
+ - Offer a way to see the full changes, such as a View Changes button, before the approve button is pressed.
19
+ - Let the person edit the plan or cancel it, not only approve it.
20
+ - Once decided, mark the card Approved or Cancelled and remove its buttons.
21
+
22
+ ## Don't
23
+
24
+ - Do not carry out a risky action before the person approves it.
25
+ - Do not replace the steps or the changes with a one-line summary.
26
+ - Do not let the agent write the label of an approve or merge button.
27
+ - Do not let a second click on a decided card approve or cancel it again.
28
+
29
+ Seen in: Scindo.
@@ -0,0 +1,27 @@
1
+ # An agent cancels and reports when nobody answers
2
+
3
+ The agent has asked a question or proposed an action, and nobody answers.
4
+
5
+ ## Answer
6
+
7
+ The agent never takes silence as a yes: while a question or proposal waits, it does nothing that depends on the answer. Each product sets the waiting time and shows it on the waiting card. When the time is up, the agent cancels the request, marks the card Cancelled, and posts one line saying what it did not do. The agent may write a plan that lists the unanswered questions as open questions. It may not carry out anything that depends on an answer.
8
+
9
+ **Not built yet:** No product cancels a waiting request on its own yet. In Scindo a request waits until a person answers, cancels or skips it, and the waiting time is not decided.
10
+
11
+ ## Why
12
+
13
+ An agent that acts on silence does work nobody approved, and one that waits forever leaves work stuck without saying so.
14
+
15
+ ## Do
16
+
17
+ - Keep the card and its buttons open until someone answers or the request is cancelled.
18
+ - Notify the person who asked when the agent needs their answer.
19
+ - When a request is cancelled, mark the card Cancelled and post one line on what was not done.
20
+ - List questions asked before a plan that nobody answered as open questions in that plan.
21
+
22
+ ## Don't
23
+
24
+ - Do not treat no answer as approval.
25
+ - Do not cancel a request without saying so in the thread.
26
+
27
+ Seen in: Scindo.
@@ -0,0 +1,31 @@
1
+ # An agent refuses clearly
2
+
3
+ The product will not let the agent answer a request, for example because the workspace used all its agent replies for the month, reached its spending cap, or sent too many requests at once.
4
+
5
+ ## Answer
6
+
7
+ The refusal says in one plain sentence which limit was reached, and either who can change it or when to try again. A person who can lift the limit gets the one button that does it, such as Upgrade or Change Budget Cap. When an admin can lift the limit, everyone else is told to ask a workspace admin. A limit that passes with time says when to try again instead.
8
+
9
+ **Not built yet:** Scindo on the web does not follow this yet: it shows the Upgrade button to everyone. Scindo's Apple app shows it only to admins.
10
+
11
+ ## Why
12
+
13
+ A person who is refused needs to know why and what to do next, or they will just send the request again.
14
+
15
+ ## Do
16
+
17
+ - Say which limit was reached, with the number when there is one: 'You've used all 50 AI agent responses this month.'
18
+ - Say who can change it, or when to try again: 'Try again in a minute.'
19
+ - Show the button that lifts the limit only to a person allowed to use it.
20
+ - Let the person close the refusal without acting, with a button such as 'Not Now'.
21
+
22
+ ## Don't
23
+
24
+ - Do not show a general error message for a refusal.
25
+ - Do not show an Upgrade button to someone who cannot upgrade.
26
+
27
+ ## Native
28
+
29
+ On Apple the refusal is a row above the composer, with an Upgrade or Change Budget Cap button for admins and never a link to a web page.
30
+
31
+ Seen in: Scindo.
@@ -0,0 +1,29 @@
1
+ # An agent says what it is
2
+
3
+ The agent posts in a thread where people also write, or replies to a person.
4
+
5
+ ## Answer
6
+
7
+ Every agent message has marks no person's message has. It shows an icon avatar instead of a photo, and the agent's own name. When the product knows which model wrote the reply, it shows the model name in small text next to the time. An agent the workspace connects from outside gets a plain bot icon, not the product's logo.
8
+
9
+ ## Why
10
+
11
+ People must see at a glance whether a person or an agent wrote what they are reading, and whose agent it is.
12
+
13
+ ## Do
14
+
15
+ - Show the agent with an icon avatar, never a photo or an initial.
16
+ - Name the agent in the message header: its role or given name, or 'Agent' when it has none.
17
+ - Show the model name next to the time when the product knows it.
18
+ - Show the product's logo on the product's own agent and a plain bot icon on an agent from outside, so people see whose agent it is.
19
+
20
+ ## Don't
21
+
22
+ - Do not show a photo for an agent, even when one is set.
23
+ - Do not show the product's logo on an agent the product does not run.
24
+
25
+ ## Native
26
+
27
+ On Apple an 'Agent' label with a sparkles icon sits next to a named agent's name, and the app draws the agent's avatar itself.
28
+
29
+ Seen in: Scindo.
@@ -0,0 +1,30 @@
1
+ # An agent shows its progress
2
+
3
+ The agent is working on a request and its reply is not ready yet.
4
+
5
+ ## Answer
6
+
7
+ While it works, the agent shows a live row in the thread, where its reply will appear: its name, the model, the seconds so far, the steps it has finished with a check mark, and the step it is on now in plain words, such as 'Reading file'. A Stop button stays on that row for the whole run. When the run is stopped, the agent posts a short note that it stopped.
8
+
9
+ ## Why
10
+
11
+ A person waiting on an agent needs to know it is still working, what it is doing, and that they can stop it.
12
+
13
+ ## Do
14
+
15
+ - Show the progress row in the thread, where the reply will appear.
16
+ - Name the current step in plain words, such as 'Reading file' or 'Editing code'.
17
+ - Keep finished steps in view, each with a check mark.
18
+ - Keep a Stop button on the row for the whole run.
19
+
20
+ ## Don't
21
+
22
+ - Do not show a spinner with no words.
23
+ - Do not hide the Stop button while the agent writes its reply.
24
+ - Do not say the agent stopped before the run has really ended.
25
+
26
+ ## Native
27
+
28
+ On Apple the Send button turns into Stop while the agent works, and the note reads 'Stopped.' only once the run has really ended.
29
+
30
+ Seen in: Scindo.
@@ -0,0 +1,26 @@
1
+ # An agent shows its sources
2
+
3
+ The agent answers from things it read: documents, files, chat, tasks, or a connected service such as a code host or a design tool.
4
+
5
+ ## Answer
6
+
7
+ Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section.
8
+
9
+ ## Why
10
+
11
+ A person can check an answer only when they can open what it came from.
12
+
13
+ ## Do
14
+
15
+ - Put the sources directly under the reply they support.
16
+ - Show each source as a card with its title and where it lives, such as the space name or the date.
17
+ - Make each card open the source itself, in the product or on the service it came from.
18
+ - Show the first six sources and a 'Show N more' button for the rest.
19
+
20
+ ## Don't
21
+
22
+ - Do not show a sources section when the reply used no sources.
23
+ - Do not show source cards on a person's message.
24
+ - Do not link a source card to any site other than the product or the service the source came from.
25
+
26
+ Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function LoginCentered(): import("react").JSX.Element;
@@ -0,0 +1,69 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Image from '../../components/image';
4
+ import TabsContainer from '../../components/tabsContainer';
5
+ import Tab from '../../components/tab';
6
+ import Form from '../../components/form';
7
+ import Alert from '../../components/alert';
8
+ import TextField from '../../components/textField';
9
+ import Button from '../../components/button';
10
+ import Line from '../../components/line';
11
+ import BrandIcon from '../../components/brandIcon';
12
+ import { Center } from '../../components/layout';
13
+ // The product's mark. A real app passes its own file.
14
+ var productMark = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
15
+ // A real app passes the router from its framework, such as Next's useRouter().
16
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
17
+ // A small check: some text, an @, then some text.
18
+ function looksLikeEmail(value) {
19
+ return /^[^@\s]+@[^@\s]+$/.test(value);
20
+ }
21
+ export default function LoginCentered() {
22
+ var _a = useState('ada@example.com'), email = _a[0], setEmail = _a[1];
23
+ var _b = useState(''), password = _b[0], setPassword = _b[1];
24
+ var _c = useState(''), error = _c[0], setError = _c[1];
25
+ var _d = useState(''), emailError = _d[0], setEmailError = _d[1];
26
+ var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
27
+ var _f = useState(false), loading = _f[0], setLoading = _f[1];
28
+ function handleSubmit() {
29
+ if (loading)
30
+ return;
31
+ setError('');
32
+ setEmailError('');
33
+ setPasswordError('');
34
+ if (!email.trim()) {
35
+ setEmailError('Enter your email.');
36
+ return;
37
+ }
38
+ if (!looksLikeEmail(email.trim())) {
39
+ setEmailError('Enter a valid email address.');
40
+ return;
41
+ }
42
+ if (!password) {
43
+ setPasswordError('Enter your password.');
44
+ return;
45
+ }
46
+ setLoading(true);
47
+ // Stands in for the request to the server.
48
+ setTimeout(function () {
49
+ setLoading(false);
50
+ setError('That email and password do not match.');
51
+ }, 1200);
52
+ }
53
+ return (<Center fill>
54
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
55
+ <TabsContainer>
56
+ <Tab label="Log In" isSelected onClickTab={function () { }}/>
57
+ <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={function () { }}/>
58
+ </TabsContainer>
59
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
60
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
61
+ <TextField id="login-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
62
+ <TextField id="login-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
63
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
64
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot password?"/>
65
+ </Form>
66
+ <Line label="or"/>
67
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
68
+ </Center>);
69
+ }
@@ -0,0 +1 @@
1
+ export default function LoginEmailOnly(): import("react").JSX.Element;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Surface from '../../components/surface';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import Form from '../../components/form';
7
+ import Alert from '../../components/alert';
8
+ import TextField from '../../components/textField';
9
+ import Button from '../../components/button';
10
+ import { Center, Stack } from '../../components/layout';
11
+ // A small check: some text, an @, then some text.
12
+ function looksLikeEmail(value) {
13
+ return /^[^@\s]+@[^@\s]+$/.test(value);
14
+ }
15
+ export default function LoginEmailOnly() {
16
+ var _a = useState('ada@example.com'), email = _a[0], setEmail = _a[1];
17
+ var _b = useState(''), sentTo = _b[0], setSentTo = _b[1];
18
+ var _c = useState(''), emailError = _c[0], setEmailError = _c[1];
19
+ var _d = useState(false), loading = _d[0], setLoading = _d[1];
20
+ function handleSubmit() {
21
+ if (loading)
22
+ return;
23
+ setEmailError('');
24
+ setSentTo('');
25
+ if (!email.trim()) {
26
+ setEmailError('Enter your email.');
27
+ return;
28
+ }
29
+ if (!looksLikeEmail(email.trim())) {
30
+ setEmailError('Enter a valid email address.');
31
+ return;
32
+ }
33
+ setLoading(true);
34
+ var address = email.trim();
35
+ // Stands in for the request to the server.
36
+ setTimeout(function () {
37
+ setLoading(false);
38
+ setSentTo(address);
39
+ }, 1200);
40
+ }
41
+ return (<Center fill>
42
+ <Surface padding="large">
43
+ <Stack gap="xlarge">
44
+ <Stack gap="small">
45
+ <Heading level={2} size="h5">Log in</Heading>
46
+ <Paragraph tone="secondary" size="body2" measure="none">We will email you a link to sign in.</Paragraph>
47
+ </Stack>
48
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
49
+ {sentTo && <Alert type="success" variant="inline" message={"We sent a sign-in link to ".concat(sentTo, ".")} showCloseButton onClose={function () { return setSentTo(''); }}/>}
50
+ <TextField id="email-only-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
51
+ <Button size="medium" type="primary" state="enabled" label="Send sign-in link" htmlType="submit" loading={loading}/>
52
+ </Form>
53
+ </Stack>
54
+ </Surface>
55
+ </Center>);
56
+ }
@@ -0,0 +1 @@
1
+ export default function LoginProviderFirst(): import("react").JSX.Element;
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Form from '../../components/form';
5
+ import Alert from '../../components/alert';
6
+ import TextField from '../../components/textField';
7
+ import Button from '../../components/button';
8
+ import Line from '../../components/line';
9
+ import BrandIcon from '../../components/brandIcon';
10
+ import { Center, Stack } from '../../components/layout';
11
+ // A small check: some text, an @, then some text.
12
+ function looksLikeEmail(value) {
13
+ return /^[^@\s]+@[^@\s]+$/.test(value);
14
+ }
15
+ export default function LoginProviderFirst() {
16
+ var _a = useState('ada@example.com'), email = _a[0], setEmail = _a[1];
17
+ var _b = useState(''), password = _b[0], setPassword = _b[1];
18
+ var _c = useState(''), error = _c[0], setError = _c[1];
19
+ var _d = useState(''), emailError = _d[0], setEmailError = _d[1];
20
+ var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
21
+ var _f = useState(false), loading = _f[0], setLoading = _f[1];
22
+ function handleSubmit() {
23
+ if (loading)
24
+ return;
25
+ setError('');
26
+ setEmailError('');
27
+ setPasswordError('');
28
+ if (!email.trim()) {
29
+ setEmailError('Enter your email.');
30
+ return;
31
+ }
32
+ if (!looksLikeEmail(email.trim())) {
33
+ setEmailError('Enter a valid email address.');
34
+ return;
35
+ }
36
+ if (!password) {
37
+ setPasswordError('Enter your password.');
38
+ return;
39
+ }
40
+ setLoading(true);
41
+ // Stands in for the request to the server.
42
+ setTimeout(function () {
43
+ setLoading(false);
44
+ setError('That email and password do not match.');
45
+ }, 1200);
46
+ }
47
+ return (<Center fill>
48
+ <Heading level={2} size="h5">Sign in to Acme</Heading>
49
+ <Stack gap="medium">
50
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
51
+ <Button size="medium" type="secondary" state="enabled" label="Continue with GitHub" decoIcon={<BrandIcon name="github"/>}/>
52
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Apple" decoIcon={<BrandIcon name="apple"/>}/>
53
+ </Stack>
54
+ <Line label="or"/>
55
+ <Form aria-label="Sign in with email" onSubmit={handleSubmit}>
56
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
57
+ <TextField id="provider-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
58
+ <TextField id="provider-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
59
+ <Button size="medium" type="primary" state="enabled" label="Sign in with email" htmlType="submit" loading={loading}/>
60
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot password?"/>
61
+ </Form>
62
+ </Center>);
63
+ }
@@ -0,0 +1 @@
1
+ export default function LoginSplit(): import("react").JSX.Element;
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Image from '../../components/image';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import Form from '../../components/form';
7
+ import Alert from '../../components/alert';
8
+ import TextField from '../../components/textField';
9
+ import Button from '../../components/button';
10
+ import Line from '../../components/line';
11
+ import Link from '../../components/link';
12
+ import BrandIcon from '../../components/brandIcon';
13
+ import { Center, Cluster, Split, Stack } from '../../components/layout';
14
+ // The product's mark. A real app passes its own file.
15
+ var productMark = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
16
+ // A small check: some text, an @, then some text.
17
+ function looksLikeEmail(value) {
18
+ return /^[^@\s]+@[^@\s]+$/.test(value);
19
+ }
20
+ export default function LoginSplit() {
21
+ var _a = useState('ada@example.com'), email = _a[0], setEmail = _a[1];
22
+ var _b = useState(''), password = _b[0], setPassword = _b[1];
23
+ var _c = useState(''), error = _c[0], setError = _c[1];
24
+ var _d = useState(''), emailError = _d[0], setEmailError = _d[1];
25
+ var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
26
+ var _f = useState(false), loading = _f[0], setLoading = _f[1];
27
+ function handleSubmit() {
28
+ if (loading)
29
+ return;
30
+ setError('');
31
+ setEmailError('');
32
+ setPasswordError('');
33
+ if (!email.trim()) {
34
+ setEmailError('Enter your email.');
35
+ return;
36
+ }
37
+ if (!looksLikeEmail(email.trim())) {
38
+ setEmailError('Enter a valid email address.');
39
+ return;
40
+ }
41
+ if (!password) {
42
+ setPasswordError('Enter your password.');
43
+ return;
44
+ }
45
+ setLoading(true);
46
+ // Stands in for the request to the server.
47
+ setTimeout(function () {
48
+ setLoading(false);
49
+ setError('That email and password do not match.');
50
+ }, 1200);
51
+ }
52
+ return (<Split fill aside={<Stack gap="large">
53
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
54
+ <Heading level={2} size="h4">Plan the week with your whole team.</Heading>
55
+ <Paragraph tone="secondary" measure="lede">
56
+ Acme keeps tasks, notes and decisions in one place.
57
+ </Paragraph>
58
+ </Stack>}>
59
+ <Center fill>
60
+ <Heading level={2} size="h5">Log in to Acme</Heading>
61
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
62
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
63
+ <TextField id="split-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
64
+ <TextField id="split-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
65
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
66
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot password?"/>
67
+ </Form>
68
+ <Line label="or"/>
69
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
70
+ <Cluster gap="small">
71
+ <Paragraph tone="secondary" size="body2" measure="none">New here?</Paragraph>
72
+ <Link href="/signup" size="body2">Create an account</Link>
73
+ </Cluster>
74
+ </Center>
75
+ </Split>);
76
+ }