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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
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
import React, { FunctionComponent, ButtonHTMLAttributes, useState } from 'react'; | |
import uuid from 'uuid/v4'; | |
import classnames from 'classnames'; | |
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | |
primary?: boolean, | |
accent?: boolean, | |
circle?: boolean, | |
ripple?: boolean, | |
additionalClass?: string, |
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
function onAnimationEnd(key: string) { | |
setRippleElements(rippleElements => rippleElements.filter(element => element.key !== key)); | |
} |
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
function onRippleClick(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) { | |
var rect = event.currentTarget.getBoundingClientRect(); | |
const d = Math.max(event.currentTarget.clientWidth, event.currentTarget.clientHeight); | |
const left = event.clientX - rect.left - d/2 + 'px'; | |
const top = event.clientY - rect.top - d/2 + 'px'; | |
const rippleElement = newRippleElement(d, left, top); | |
setRippleElements([...rippleElements, rippleElement]); | |
} |
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
... | |
const [rippleElements, setRippleElements] = useState<JSX.Element[]>([]); | |
... | |
function renderRippleElements() { | |
return rippleElements; | |
} |
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
.with-ripple { | |
@apply relative overflow-hidden; | |
@keyframes ripple { | |
to { | |
@apply opacity-0; | |
transform: scale(2.5); | |
} | |
} |
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
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | |
primary?: boolean, | |
accent?: boolean, | |
additionalClass?: string, | |
} | |
... | |
const classNames = classnames( | |
'btn', |
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
import React, { FunctionComponent } from 'react'; | |
export interface ButtonProps { | |
} | |
const Button: FunctionComponent<ButtonProps> = (props) => { | |
return ( | |
<button className="btn">props.children</button> | |
); | |
} |
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
&:hover { | |
background-color: var(--grey04); | |
} | |
&.accent { | |
color: var(--blue01); | |
} | |
&.primary { | |
@apply text-white; |
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
.btn { | |
@apply text-black text-base leading-snug; | |
@apply py-3 px-4 border-none rounded-lg; | |
@apply inline-block cursor-pointer no-underline; | |
&:focus { | |
@apply outline-none; | |
} | |
} |
NewerOlder