blob: 2233e9c844f3bc6048b28227bf141d192752e583 [file] [log] [blame]
pineafan15b813d2022-02-13 10:06:09 +00001import react, { Component } from "react";
2import Styles from '../styles/Components/texttools.module.css';
3import { Popover } from 'react-tiny-popover';
4
5
6class List extends Component {
7 constructor(props) {
8 super(props);
9 }
10
11 render() {
12 return (
13 <div className={Styles.list}>
14 {
15 react.Children.toArray(this.props.children).map((item, index) => {
16 return <div key={index} className={Styles.listItem}>
17 <div className={Styles.square} style={{borderColor: `#${this.props.colour}`}} />
18 <div>{item}</div>
19 </div>
20 })
21 }
22 </div>
23 )
24 }
25}
26
27class ListItem extends Component {
28 render() {
29 return this.props.children
30 }
31}
32
33class Code extends Component {
34 constructor(props) {
35 super(props);
36 this.state = {
37 isPopoverOpen: false,
38 };
39 }
40
41 clicked() {
42 let content = this.props.children
43 navigator.clipboard.writeText(content)
44 this.setState({isPopoverOpen: true})
45 setTimeout(() => {
46 this.setState({isPopoverOpen: false})
pineafanff3d4522022-05-06 19:51:02 +010047 }, 2000)
pineafan15b813d2022-02-13 10:06:09 +000048 }
49
50 render() {
pineafanff3d4522022-05-06 19:51:02 +010051 return <pre
52 className={Styles.code}
53 style={{color: `#${this.props.colour}`}}
54 onClick={this.props.clickable ? () => this.clicked() : () => this.clicked()}
55 >{this.state.isPopoverOpen ? "Copied!" : this.props.children}</pre>
pineafan15b813d2022-02-13 10:06:09 +000056 }
57}
58
59export { List, ListItem, Code };