This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docz-theme-default): add copy to clipboard on pre
- Loading branch information
1 parent
fb1ac49
commit 78149ad
Showing
6 changed files
with
133 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import styled from 'react-emotion' | ||
|
||
export const Button = styled('button')` | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
outline: none; | ||
border: none; | ||
` | ||
|
||
export const ButtonLink = styled(Button)` | ||
background: transparent; | ||
` |
34 changes: 34 additions & 0 deletions
34
packages/docz-theme-default/src/components/ui/ButtonSwap.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as React from 'react' | ||
import { SFC } from 'react' | ||
import { Toggle } from 'react-powerplug' | ||
|
||
import { Button as BaseButton } from './Button' | ||
|
||
type AnimatedButtonProps = React.ButtonHTMLAttributes<any> & { | ||
swap: React.ReactNode | ||
as?: React.ComponentType<React.ButtonHTMLAttributes<any>> | ||
} | ||
|
||
export const ButtonSwap: SFC<AnimatedButtonProps> = ({ | ||
as: Button = BaseButton, | ||
onClick, | ||
swap, | ||
children, | ||
...props | ||
}) => ( | ||
<Toggle> | ||
{({ toggle, on }: any) => { | ||
const handleClick = (ev: any) => { | ||
toggle() | ||
onClick && onClick(ev) | ||
setTimeout(toggle, 500) | ||
} | ||
|
||
return ( | ||
<Button onClick={handleClick} {...props}> | ||
{on ? swap : children} | ||
</Button> | ||
) | ||
}} | ||
</Toggle> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters