Skip to content

Commit 5bde986

Browse files
authored
feat(playground): buttons now show tooltips (ionic-team#2234)
1 parent b7c1214 commit 5bde986

4 files changed

Lines changed: 78 additions & 4 deletions

File tree

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@ionic-internal/ionic-ds": "^7.0.0",
4747
"@mdx-js/react": "^1.6.22",
4848
"@stackblitz/sdk": "^1.6.0",
49+
"@tippyjs/react": "^4.2.6",
4950
"clsx": "^1.1.1",
5051
"concurrently": "^6.2.0",
5152
"crowdin": "^3.5.0",

src/components/global/Playground/index.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { EditorOptions, openAngularEditor, openHtmlEditor, openReactEditor, open
55
import { Mode, UsageTarget } from './playground.types';
66
import useThemeContext from '@theme/hooks/useThemeContext';
77

8+
import Tippy from '@tippyjs/react';
9+
import 'tippy.js/dist/tippy.css';
810

911
const ControlButton = ({ isSelected, handleClick, title, label }) => {
1012
return (
@@ -156,7 +158,8 @@ export default function Playground({
156158
/>
157159
</div>
158160
<div className="playground__control-group playground__control-group--end">
159-
<button
161+
<Tippy theme="playground" arrow={false} placement="bottom" content={codeExpanded ? 'Hide source code' : 'Show full source'}>
162+
<button
160163
className="playground__icon-button playground__icon-button--primary"
161164
aria-label={codeExpanded ? 'Hide source code' : 'Show full source'}
162165
onClick={() => setCodeExpanded(!codeExpanded)}
@@ -173,7 +176,9 @@ export default function Playground({
173176
<path d="M11 9L15 5L11 1" stroke="current" strokeLinecap="round" strokeLinejoin="round" />
174177
</svg>
175178
</button>
176-
<a
179+
</Tippy>
180+
<Tippy theme="playground" arrow={false} placement="bottom" content="Report an issue">
181+
<a
177182
className="playground__icon-button"
178183
href="https://github.com/ionic-team/ionic-docs/issues/new/choose"
179184
aria-label="Report an issue"
@@ -187,7 +192,9 @@ export default function Playground({
187192
/>
188193
</svg>
189194
</a>
190-
<button className="playground__icon-button playground__icon-button--primary" onClick={copySourceCode}>
195+
</Tippy>
196+
<Tippy theme="playground" arrow={false} placement="bottom" content="Copy source code">
197+
<button className="playground__icon-button playground__icon-button--primary" onClick={copySourceCode}>
191198
<svg
192199
aria-hidden="true"
193200
xmlns="http://www.w3.org/2000/svg"
@@ -203,7 +210,9 @@ export default function Playground({
203210
<rect x="3" y="3" width="8" height="8" rx="1.5" stroke="current" />
204211
</svg>
205212
</button>
206-
<button className="playground__icon-button playground__icon-button--primary" onClick={openEditor}>
213+
</Tippy>
214+
<Tippy theme="playground" arrow={false} placement="bottom" content="Open in StackBlitz">
215+
<button className="playground__icon-button playground__icon-button--primary" onClick={openEditor}>
207216
<svg
208217
aria-hidden="true"
209218
width="12"
@@ -221,6 +230,7 @@ export default function Playground({
221230
/>
222231
</svg>
223232
</button>
233+
</Tippy>
224234
</div>
225235
</div>
226236
<div className="playground__preview">

src/components/global/Playground/playground.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,15 @@
191191
.playground iframe.frame-hidden {
192192
display: none;
193193
}
194+
195+
/* Tooltip styling */
196+
.tippy-box[data-theme="playground"] {
197+
background-color: var(--c-carbon-90);
198+
border-radius: 8px;
199+
line-height: initial;
200+
font-size: 12px;
201+
}
202+
203+
.tippy-box[data-theme="playground"] .tippy-content {
204+
padding: 6px 10px;
205+
}

0 commit comments

Comments
 (0)