1 1
import React from 'react'
2 1
import PropTypes from 'prop-types'
3 1
import { MdFullscreen, MdFullscreenExit } from 'react-icons/md'
4 1
import ToolbarButton from 'rsg-components/ToolbarButton'
5 1
import getUrl from 'react-styleguidist/lib/client/utils/getUrl'
6

7
export interface IsolateButtonProps {
8
	name: string
9
	example?: number
10
	isolated?: boolean
11
}
12

13 1
const IsolateButton = ({ name, example, isolated }: IsolateButtonProps) => {
14 1
	const testID = example ? `${name}-${example}-isolate-button` : `${name}-isolate-button`
15

16 1
	return isolated ? (
17 1
		<ToolbarButton
18
			href={getUrl({ anchor: true, slug: name.toLowerCase() })}
19
			title="Show all components"
20
			testId={testID}
21
		>
22
			<MdFullscreenExit />
23
		</ToolbarButton>
24
	) : (
25 1
		<ToolbarButton
26
			href={getUrl({ name, example, isolated: true })}
27
			title="Open isolated"
28
			testId={testID}
29
		>
30
			<MdFullscreen />
31
		</ToolbarButton>
32
	)
33
}
34

35 1
IsolateButton.propTypes = {
36
	name: PropTypes.string.isRequired,
37
	example: PropTypes.number,
38
	isolated: PropTypes.bool
39
}
40

41 1
export default IsolateButton

Read our documentation on viewing source code .

Loading