From 91978fe2063fb2dcda00b1258f7f54c4923ac403 Mon Sep 17 00:00:00 2001 From: thollander Date: Sun, 5 May 2019 22:23:01 +0200 Subject: [PATCH] Add copy button for individual story - Resolves #6708 --- lib/ui/package.json | 1 + .../__snapshots__/preview.stories.storyshot | 20 +++++++++---------- lib/ui/src/components/preview/preview.js | 19 ++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/lib/ui/package.json b/lib/ui/package.json index 356f65315773..1561b20e7c94 100644 --- a/lib/ui/package.json +++ b/lib/ui/package.json @@ -29,6 +29,7 @@ "@storybook/core-events": "5.1.0-beta.0", "@storybook/router": "5.1.0-beta.0", "@storybook/theming": "5.1.0-beta.0", + "copy-to-clipboard": "^3.0.8", "core-js": "^3.0.1", "core-js-pure": "^3.0.1", "fast-deep-equal": "^2.0.1", diff --git a/lib/ui/src/components/preview/__snapshots__/preview.stories.storyshot b/lib/ui/src/components/preview/__snapshots__/preview.stories.storyshot index 6c0bc9320fe5..fb1bdad30de7 100644 --- a/lib/ui/src/components/preview/__snapshots__/preview.stories.storyshot +++ b/lib/ui/src/components/preview/__snapshots__/preview.stories.storyshot @@ -2,7 +2,7 @@ exports[`Storyshots UI|Preview/Preview no tabs 1`] = ` Array [ - .emotion-22 { + .emotion-25 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -39,7 +39,7 @@ Array [ margin-left: 15px; } -.emotion-21 { +.emotion-24 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -54,7 +54,7 @@ Array [ margin-left: 30px; } -.emotion-21 > * { +.emotion-24 > * { margin-right: 15px; } @@ -70,7 +70,7 @@ Array [ fill: currentColor; } -.emotion-23 { +.emotion-26 { overflow-y: hidden; overflow-x: auto; color: #999999; @@ -133,7 +133,7 @@ Array [ }
* { +.emotion-30 > * { margin-right: 15px; } @@ -509,7 +509,7 @@ Array [ fill: currentColor; } -.emotion-29 { +.emotion-32 { overflow-y: hidden; overflow-x: auto; color: #999999; @@ -579,7 +579,7 @@ Array [ }
), }, + { + match: p => p.viewMode === 'story', + render: () => ( + + copy( + `${window.location.origin}${ + window.location.pathname + }${baseUrl}?id=${storyId}${stringifyQueryParams(queryParams)}` + ) + } + title="Copy canvas link" + > + + + ), + }, ]); const filter = item =>