Samuel Shuert | 016ea02 | 2021-09-01 16:17:24 -0500 | [diff] [blame] | 1 | import { Component } from "react"; |
pineafan | e0283a8 | 2022-02-13 10:05:56 +0000 | [diff] [blame] | 2 | import Styles from '../styles/Components/card.module.css'; |
pineafan | 5b612d9 | 2022-02-17 19:22:50 +0000 | [diff] [blame] | 3 | import react from 'react' |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 4 | import { withRouter } from "next/router"; |
Samuel Shuert | 016ea02 | 2021-09-01 16:17:24 -0500 | [diff] [blame] | 5 | |
| 6 | class Card extends Component { |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame^] | 7 | constructor(props) { |
| 8 | super(props); |
Samuel Shuert | 52f3777 | 2021-09-02 12:29:40 -0500 | [diff] [blame] | 9 | } |
Samuel Shuert | 016ea02 | 2021-09-01 16:17:24 -0500 | [diff] [blame] | 10 | |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame^] | 11 | render() { |
| 12 | return ( |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 13 | <div className={Styles.card} style={{ |
pineafan | a5ce910 | 2021-09-02 17:21:31 +0100 | [diff] [blame] | 14 | margin: "0" |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 15 | }} onClick={this.props.url ? () => { this.props.router.push(this.props.url)} : null}> |
| 16 | <div className={Styles.backgroundGradient} style={{ |
pineafan | a841c76 | 2021-11-14 21:21:04 +0000 | [diff] [blame] | 17 | backgroundImage: `linear-gradient(69.44deg, #${this.props.gradient[0]} 0%, #${this.props.gradient[1]} 100%)` |
| 18 | }} /> |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 19 | <img alt="" className={Styles.backgroundImage} src={`https://assets.clicks.codes/web/waves/card/${this.props.wave}.svg`} draggable={false} /> |
| 20 | <div className={Styles.panel} onClick={() => { this.props.url ? () => { this.props.router.push(this.props.url)} : null}}> |
pineafan | a5ce910 | 2021-09-02 17:21:31 +0100 | [diff] [blame] | 21 | <div className={Styles.titleContainer}> |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 22 | <img alt="Project icon" className={Styles.image} src={"https://assets.clicks.codes/" + (this.props.icon ? this.props.icon : this.props.wave) + ".svg"} /> |
pineafan | a5ce910 | 2021-09-02 17:21:31 +0100 | [diff] [blame] | 23 | <h1 className={Styles.title}>{this.props.title}</h1> |
| 24 | </div> |
| 25 | <p className={Styles.subtext}>{this.props.subtext}</p> |
| 26 | <div className={Styles.buttonLayout}> |
| 27 | { |
Samuel Shuert | 604e31d | 2021-09-02 16:06:20 -0500 | [diff] [blame] | 28 | this.props.buttons ? this.props.buttons.map((button, i) => { |
pineafan | a5ce910 | 2021-09-02 17:21:31 +0100 | [diff] [blame] | 29 | return <a |
Samuel Shuert | 604e31d | 2021-09-02 16:06:20 -0500 | [diff] [blame] | 30 | key={i} |
pineafan | a5ce910 | 2021-09-02 17:21:31 +0100 | [diff] [blame] | 31 | className={Styles.button} |
| 32 | style={{backgroundColor:`#${button.color}`, color:`#${this.props.buttonText}`}} |
Samuel Shuert | 52f3777 | 2021-09-02 12:29:40 -0500 | [diff] [blame] | 33 | href={button.link} |
pineafan | aed3024 | 2021-09-04 09:33:40 +0100 | [diff] [blame] | 34 | target={button.newTab ? "_blank" : undefined} |
pineafan | 0a17873 | 2022-02-09 21:00:05 +0000 | [diff] [blame] | 35 | rel="noreferrer">{button.text} |
pineafan | a5ce910 | 2021-09-02 17:21:31 +0100 | [diff] [blame] | 36 | </a> |
| 37 | }) : null |
| 38 | } |
| 39 | </div> |
Samuel Shuert | 016ea02 | 2021-09-01 16:17:24 -0500 | [diff] [blame] | 40 | </div> |
| 41 | </div> |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 42 | ); |
| 43 | } |
Samuel Shuert | 016ea02 | 2021-09-01 16:17:24 -0500 | [diff] [blame] | 44 | } |
| 45 | |
pineafan | 5b612d9 | 2022-02-17 19:22:50 +0000 | [diff] [blame] | 46 | class CardRow extends Component { |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame^] | 47 | constructor(props) { |
| 48 | super(props); |
| 49 | } |
pineafan | 5b612d9 | 2022-02-17 19:22:50 +0000 | [diff] [blame] | 50 | |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame^] | 51 | render() { |
| 52 | return ( |
pineafan | 5b612d9 | 2022-02-17 19:22:50 +0000 | [diff] [blame] | 53 | <div className={Styles.container}> |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame^] | 54 | { |
| 55 | react.Children.toArray(this.props.children).map((item, index) => { |
| 56 | return <div className={Styles.item} key={index}>{item}</div> |
| 57 | }) |
| 58 | } |
| 59 | </div> |
pineafan | 5b612d9 | 2022-02-17 19:22:50 +0000 | [diff] [blame] | 60 | ) |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame^] | 61 | } |
pineafan | 5b612d9 | 2022-02-17 19:22:50 +0000 | [diff] [blame] | 62 | } |
| 63 | |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 64 | Card = withRouter(Card); |
| 65 | |
| 66 | export { Card, CardRow }; |