@khanacademy/wonder-blocks-button 2.10.1 → 2.11.2

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.
@@ -48,8 +48,7 @@ DefaultButton.args = {
48
48
  DefaultButton.parameters = {
49
49
  design: {
50
50
  type: "figma",
51
- url:
52
- "https://www.figma.com/file/VbVu3h2BpBhH80niq101MHHE/Wonder-Blocks-(Web)?node-id=401%3A307",
51
+ url: "https://www.figma.com/file/VbVu3h2BpBhH80niq101MHHE/Wonder-Blocks-(Web)?node-id=401%3A307",
53
52
  },
54
53
  chromatic: {
55
54
  // We already have screenshots of other stories that cover more of the button states
@@ -353,7 +352,7 @@ ButtonsWithRouter.parameters = {
353
352
  },
354
353
  };
355
354
 
356
- export const NavigationWithAsyncAction: StoryComponentType = () => (
355
+ export const BeforeNavCallbacks: StoryComponentType = () => (
357
356
  <MemoryRouter>
358
357
  <View style={styles.row}>
359
358
  <Button
@@ -365,7 +364,7 @@ export const NavigationWithAsyncAction: StoryComponentType = () => (
365
364
  })
366
365
  }
367
366
  >
368
- Async action, client-side nav
367
+ beforeNav, client-side nav
369
368
  </Button>
370
369
  <Button
371
370
  href="/foo"
@@ -377,7 +376,7 @@ export const NavigationWithAsyncAction: StoryComponentType = () => (
377
376
  })
378
377
  }
379
378
  >
380
- Async action, server-side nav
379
+ beforeNav, server-side nav
381
380
  </Button>
382
381
  <Button
383
382
  href="https://google.com"
@@ -389,7 +388,7 @@ export const NavigationWithAsyncAction: StoryComponentType = () => (
389
388
  })
390
389
  }
391
390
  >
392
- Async action, open URL
391
+ beforeNav, open URL in new tab
393
392
  </Button>
394
393
  <Switch>
395
394
  <Route path="/foo">
@@ -400,10 +399,71 @@ export const NavigationWithAsyncAction: StoryComponentType = () => (
400
399
  </MemoryRouter>
401
400
  );
402
401
 
403
- NavigationWithAsyncAction.parameters = {
402
+ BeforeNavCallbacks.storyName = "beforeNav Callbacks";
403
+
404
+ BeforeNavCallbacks.parameters = {
404
405
  docs: {
405
406
  storyDescription:
406
- "Sometimes you may need to perform an async action either before or during navigation. This can be accomplished with `beforeNav` and `safeWithNav` respectively.",
407
+ "These buttons always wait until the async callback code completes before starting navigation.",
408
+ },
409
+ chromatic: {
410
+ disableSnapshot: true,
411
+ },
412
+ };
413
+
414
+ export const SafeWithNavCallbacks: StoryComponentType = () => (
415
+ <MemoryRouter>
416
+ <View style={styles.row}>
417
+ <Button
418
+ href="/foo"
419
+ style={styles.button}
420
+ safeWithNav={() =>
421
+ new Promise((resolve, reject) => {
422
+ setTimeout(resolve, 1000);
423
+ })
424
+ }
425
+ >
426
+ safeWithNav, client-side nav
427
+ </Button>
428
+ <Button
429
+ href="/foo"
430
+ style={styles.button}
431
+ skipClientNav={true}
432
+ safeWithNav={() =>
433
+ new Promise((resolve, reject) => {
434
+ setTimeout(resolve, 1000);
435
+ })
436
+ }
437
+ >
438
+ safeWithNav, server-side nav
439
+ </Button>
440
+ <Button
441
+ href="https://google.com"
442
+ style={styles.button}
443
+ skipClientNav={true}
444
+ safeWithNav={() =>
445
+ new Promise((resolve, reject) => {
446
+ setTimeout(resolve, 1000);
447
+ })
448
+ }
449
+ >
450
+ safeWithNav, open URL in new tab
451
+ </Button>
452
+ <Switch>
453
+ <Route path="/foo">
454
+ <View id="foo">Hello, world!</View>
455
+ </Route>
456
+ </Switch>
457
+ </View>
458
+ </MemoryRouter>
459
+ );
460
+
461
+ SafeWithNavCallbacks.storyName = "safeWithNav Callbacks";
462
+
463
+ SafeWithNavCallbacks.parameters = {
464
+ docs: {
465
+ storyDescription:
466
+ "If the `onClick` callback calls `preventDefault()`, then navigation will not occur.",
407
467
  },
408
468
  chromatic: {
409
469
  disableSnapshot: true,
@@ -421,7 +481,7 @@ export const PreventNavigation: StoryComponentType = () => (
421
481
  e.preventDefault();
422
482
  }}
423
483
  >
424
- This button prevent navigation.
484
+ This button prevents navigation.
425
485
  </Button>
426
486
  <Switch>
427
487
  <Route path="/foo">
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Khan Academy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.