diff --git a/Parts/Charts.js b/Parts/Charts.js
index 1f14b18..ac3d2fb 100644
--- a/Parts/Charts.js
+++ b/Parts/Charts.js
@@ -1,5 +1,5 @@
import React, { useRef, useState } from "react";
-import Chart from "chart.js";
+import Chart from 'chart.js/auto';
import Card, { CardHeader } from "./Card";
import { createPopper } from "@popperjs/core";
@@ -8,7 +8,7 @@ export function ChartTooltip({ tooltipData, ...props }) {
return (
<>
- { tooltipData.body.map((item, index) => (
+ {tooltipData.body.map((item, index) => (
{item.before + item.lines + item.after}
@@ -71,15 +71,15 @@ export default function NejChart(props) {
responsive: true,
defaultColor: [accentCol, accent2Col, accent3Col, accent4Col, accent5Col, accent6Col],
legend: {
- ...Chart.defaults.global.legend,
+ ...Chart.defaults.global?.legend,
labels: {
- ...Chart.defaults.global.legend.labels,
+ ...Chart.defaults.global?.legend?.labels,
fontColor: secondary,
usePointStyle: true
},
},
tooltips: {
- ...Chart.defaults.global.tooltips,
+ ...Chart.defaults.global?.tooltips,
backgroundColor: bgTrianry,
enabled: false,
custom: (tooltipModel) => {
@@ -125,7 +125,7 @@ export default function NejChart(props) {
console.log(Chart.defaults);
console.log(props.config);
let chart = new Chart(ctx, props.config);
- return ()=>{
+ return () => {
chart.destroy();
}
}, []);
@@ -223,7 +223,7 @@ export function ExLineChart() {
-
+
)
@@ -270,7 +270,7 @@ export function ExBarChart() {
},
],
},
- options:{
+ options: {
legend: {
display: false,
},
diff --git a/Parts/Colors.js b/Parts/Colors.js
new file mode 100644
index 0000000..707f367
--- /dev/null
+++ b/Parts/Colors.js
@@ -0,0 +1,47 @@
+
+import tw, {styled} from "twin.macro"
+import 'styled-components/macro'
+
+
+export let colors = {
+ error: tw`bg-red-600`,
+ accent: tw`bg-accent`,
+ accent2: tw`bg-accent2`,
+ accent3: tw`bg-accent3`,
+ accent4: tw`bg-accent4`,
+ accent5: tw`bg-accent5`,
+}
+
+export let colorsHover = {
+ error: tw`hover:bg-red-700`,
+ accent: tw`hover:bg-accent-dark`,
+ accent2: tw`hover:bg-accent2-dark`,
+ accent3: tw`hover:bg-accent3-dark`,
+ accent4: tw`hover:bg-accent4-dark`,
+ accent5: tw`hover:bg-accent5-dark`,
+}
+export let colorsDisabled = {
+ error: tw`disabled:bg-red-700`,
+ accent: tw`disabled:bg-accent-dark`,
+ accent2: tw`disabled:bg-accent2-dark`,
+ accent3: tw`disabled:bg-accent3-dark`,
+ accent4: tw`disabled:bg-accent4-dark`,
+ accent5: tw`disabled:bg-accent5-dark`,
+}
+
+export let textColors = {
+ error: tw`text-red-600`,
+ accent: tw`text-accent`,
+ accent2: tw`text-accent2`,
+ accent3: tw`text-accent3`,
+ accent4: tw`text-accent4`,
+ accent5: tw`text-accent5`,
+}
+export let textColorsHover = {
+ error: tw`hover:text-red-700`,
+ accent: tw`hover:text-accent-dark`,
+ accent2: tw`hover:text-accent2-dark`,
+ accent3: tw`hover:text-accent3-dark`,
+ accent4: tw`hover:text-accent4-dark`,
+ accent5: tw`hover:text-accent5-dark`,
+}
\ No newline at end of file
diff --git a/Parts/DropDown.js b/Parts/DropDown.js
index 0f8be38..5f7de52 100644
--- a/Parts/DropDown.js
+++ b/Parts/DropDown.js
@@ -1,27 +1,41 @@
-import React, { useEffect } from "react";
+import React, { cloneElement, isValidElement, useEffect, useImperativeHandle, useRef, useState } from "react";
import { createPopper } from "@popperjs/core";
-export function DropDownItem(props) {
- return
;
-}
-export default function Dropdown(props) {
+import tw, { styled } from "twin.macro"
+import 'styled-components/macro'
+import { colors, colorsDisabled, colorsHover, textColors, textColorsHover } from "./Colors";
+
+const DropDownItem = styled.button(({ type }) => [
+ // The common button styles added with the tw import
+ tw`text-sm text-left py-2 px-4 focus:outline-none block w-full whitespace-nowrap bg-transparent hover:bg-secondary disabled:bg-secondary text-primary hover:text-primary`,
+
+ // Use props to conditionally style your components
+ textColors[type], colorsHover[type]
+])
+export { DropDownItem }
+
+let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button, popper, placement, hover, ...props }, ref) => {
// dropdown props
+ const [overButton, setOverButton] = React.useState(false);
+ const [overDropDown, setOverDropDown] = React.useState(false);
+
const [dropdownPopoverShow, setDropdownPopoverShow] = React.useState(false);
+
const btnDropdownRef = React.createRef();
const popoverDropdownRef = React.createRef();
+
const openDropdownPopover = () => {
createPopper(btnDropdownRef.current, popoverDropdownRef.current, {
- placement: props.placement ?? "left-start",
+ placement: placement ?? "bottom",
+ ...popper
});
setDropdownPopoverShow(true);
+
+ onValueChanged && onValueChanged(true);
};
const closeDropdownPopover = () => {
setDropdownPopoverShow(false);
+ onValueChanged && onValueChanged(false);
};
function handleOutsideClick(event) {
@@ -31,6 +45,7 @@ export default function Dropdown(props) {
}
}
+
useEffect(() => {
if ('ontouchend' in window) {
document.addEventListener('touchend', handleOutsideClick)
@@ -44,28 +59,71 @@ export default function Dropdown(props) {
};
});
+ useImperativeHandle(ref, () => ({
+ openDropdownPopover,
+ closeDropdownPopover
+ }))
+
+ let childrenWithProps = React.Children.map(children, (item) => {
+ if (!item)
+ return;
+ let click = item.props?.onClick;
+ let close = item.props?.closeOnClick ?? true;
+ return cloneElement(item, { key: children.indexOf ? children.indexOf(item) : 0, onClick: () => { close && closeDropdownPopover(); click && click() } });
+ });
+
return (
<>
-
{
e.preventDefault();
dropdownPopoverShow ? closeDropdownPopover() : openDropdownPopover();
}}
+ onMouseEnter={() => { setOverButton(true); hover && openDropdownPopover() }}
+ onMouseLeave={() => { setOverButton(false); (!overDropDown && hover) && closeDropdownPopover() }}
>
- {props.button}
-
+ {button}
+
{ setOverDropDown(true); hover && openDropdownPopover() }}
+ onMouseLeave={() => { setOverDropDown(false); (!overButton && hover) && closeDropdownPopover() }}
+ css={[
+ (dropdownPopoverShow ? tw`block` : tw`hidden`),
+ tw`bg-trinary text-base z-50 float-left rounded-xl overflow-hidden text-left shadow-lg`,
+ dropdownCss,
+ props.css
+ ]}
>
- {props.children}
+ {dropdownPopoverShow && childrenWithProps}
>
);
-};
\ No newline at end of file
+});
+export default Dropdown;
+
+export function DropdownMenu({ children, fallback, notSelectedOne = true, ...props }) {
+ let [selectedItem, setSelectedItem] = useState(0);
+ let ref = useRef()
+
+ let btn = fallback ?? "";
+ if (children && children.length > 0)
+ btn = children[selectedItem > children.length ? 0 : selectedItem]
+
+ return <>
+
+ {
+ children && children.map((i) => {
+ if (children.indexOf(i) == selectedItem)
+ return;
+ return setSelectedItem(children.indexOf(i))}>{i}
+ })
+ }
+ {
+ (children == null || children.length <= (notSelectedOne ? 1 : 0)) && Nothing to show
+ }
+
+ >
+}
\ No newline at end of file
diff --git a/Parts/Input.js b/Parts/Input.js
index 8eaf093..2d71eb0 100644
--- a/Parts/Input.js
+++ b/Parts/Input.js
@@ -1,40 +1,46 @@
import React from 'react'
+import tw from 'twin.macro'
+import 'styled-components/macro'
-export default function Input(props) {
+export default function Input({ label, title, name, id, children, ...props }) {
return (
-
- {props.title != null ? (
-
- ) : null}
-
- {props.children}
+
+ {title && (
+
+ )}
+
+ {children}
)
}
-export function TextArea({label, title, name, id, children, ...props}) {
+export function TextArea({ label, title, name, id, children, ...props }) {
return (
-
-
-
+
+ {title && (
+
+ )}
+
{children}
)
}
-export function CheckBox({label, title, name, id, children, ...props}){
- return(
-
-
- {title != null ? (
-
- ) : null}
- {children}
-
+export function CheckBox({ label, title, name, id, children, ...props }) {
+ return (
+
+
+ {title != null ? (
+
+ ) : null
+ }
+ {children}
+
)
}
+
diff --git a/Parts/Layout.js b/Parts/Layout.js
index 7470b1e..69cf5e4 100644
--- a/Parts/Layout.js
+++ b/Parts/Layout.js
@@ -1,27 +1,18 @@
import React from 'react'
+import tw, {styled} from "twin.macro"
+import 'styled-components/macro'
-export function Full(props) {
- return
- {props.children}
-
-}
-export function Half(props) {
- return
- {props.children}
-
-}
-export function Quarter(props) {
- return
- {props.children}
-
-}
-export function Third(props) {
- return
- {props.children}
-
-}
-export function TwoThird(props) {
- return
- {props.children}
-
-}
\ No newline at end of file
+const Full = styled.div(tw`w-full lg:px-2 py-2`)
+export {Full}
+
+const Half = styled.div(tw`w-full lg:w-6/12 lg:px-2 py-2`)
+export {Half}
+
+const Quarter = styled.div(tw`w-full lg:w-6/12 xl:w-3/12 lg:px-2 py-2 `)
+export {Quarter}
+
+const Third = styled.div(tw`w-full lg:w-4/12 lg:px-2 py-2 `)
+export {Third}
+
+const TwoThird = styled.div(tw`w-full lg:w-8/12 lg:px-2 py-2 `)
+export {TwoThird}
diff --git a/Parts/Modal.js b/Parts/Modal.js
index 79321ca..bb75be5 100644
--- a/Parts/Modal.js
+++ b/Parts/Modal.js
@@ -1,9 +1,12 @@
import React from 'react'
import { Third } from './Layout'
+import tw, { styled } from "twin.macro"
+import 'styled-components/macro'
+
function Modal({ isOpen, onBackdropClick, ...props }) {
if (isOpen) {
- return
+ return
e.stopPropagation()}>
{props.children}
diff --git a/Parts/Pagination.js b/Parts/Pagination.js
new file mode 100644
index 0000000..f3a9bcf
--- /dev/null
+++ b/Parts/Pagination.js
@@ -0,0 +1,62 @@
+import Button from "./Button";
+import tw, { styled } from "twin.macro"
+import 'styled-components/macro'
+
+function CustomBtn({children, setPage, currentPage, page, css, ...props}){
+ console.log(css)
+ return
+}
+
+export default function Pagination({ currentPage, maxPages, setPage, ...props }) {
+
+ function RenderButtons() {
+ switch (maxPages) {
+ case 1:
+ return
1;
+ case 2:
+ return <>
+
1
+
2
+ >
+ case 3:
+ return <>
+
1
+
2
+
3
+ >
+ case 4:
+ return <>
+
1
+
2
+
3
+
4
+ >
+ case 5:
+ return <>
+
1
+
2
+
3
+
4
+
5
+ >
+ default: {
+ return <>
+ {currentPage > 3 &&
<}
+
{Math.max(currentPage-2,1)}
+
{Math.max(currentPage-2,1)+1}
+
{Math.max(currentPage-2,1)+2}
+ {(maxPages - currentPage) >= 1 &&
{Math.max(currentPage-2,1)+3}}
+ {(maxPages - currentPage) >= 2 &&
{Math.max(currentPage-2,1)+4}}
+ {(maxPages - currentPage) >= 3 &&
>}
+ >
+ }
+
+ }
+ }
+
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/Parts/RangeSlider.js b/Parts/RangeSlider.js
new file mode 100644
index 0000000..3d66dda
--- /dev/null
+++ b/Parts/RangeSlider.js
@@ -0,0 +1,26 @@
+import React, { useState, useEffect, useRef } from "react";
+
+import styles from "./RangeSlider.scss"
+
+import tw from 'twin.macro'
+import 'styled-components/macro'
+
+
+export function RangeSlider({ value=0, rangeType="", onChange, min=0, max=10, right = true, ...props }) {
+ let ref = useRef(null)
+
+ useEffect(() => {
+ if (ref.current) {
+ ref.current.style.left = (((Math.max(Math.min(value-min, max-min), 0)) * 100) / ((max-min)+2)) + `%`;
+ }
+ })
+
+ return (
+
+
+ {!right ? (rangeType + "" + value) : (value + "" + rangeType)}
+
+
onChange(radius)} />
+
+ );
+}
diff --git a/Parts/RangeSlider.scss b/Parts/RangeSlider.scss
new file mode 100644
index 0000000..451a1c5
--- /dev/null
+++ b/Parts/RangeSlider.scss
@@ -0,0 +1,87 @@
+
+.rs-range {
+
+ -webkit-appearance: none;
+ width: 100%;
+
+ &:focus {
+ outline: none;
+ }
+ &::-webkit-slider-runnable-track {
+ width: 100%;
+ height: 1px;
+ cursor: pointer;
+ box-shadow: none;
+ background: --accent;
+ }
+ &::-moz-range-track {
+ width: 100%;
+ height: 1px;
+ cursor: pointer;
+ background: --accent;
+ }
+ &::-webkit-slider-runnable-track {
+ width: 100%;
+ height: 8px;
+ cursor: pointer;
+ background: var(--accent);
+ }
+
+ &::-webkit-slider-thumb {
+ box-shadow: none;
+ border: 0px solid --accent;
+ box-shadow: 0px 10px 10px rgba(0,0,0,0.25);
+ height: 32px;
+ width: 22px;
+ border-radius: 22px;
+ background: var(--accent);
+ cursor: pointer;
+ -webkit-appearance: none;
+ margin-top: -12px;
+ }
+&::-moz-range-thumb{
+ box-shadow: none;
+ border: 0px solid;
+ box-shadow: 0px 10px 10px rgba(0,0,0,0.25);
+ height: 31px;
+ width: 12px;
+ border-radius: 22px;
+ background: var(--accent);
+ cursor: pointer;
+ -webkit-appearance: none;
+ margin-top: -20px;
+}
+&::-moz-focus-outer {
+ border: 0;
+ }
+}
+.rs-label {
+
+ position: relative;
+ display: block;
+ margin-bottom: 1rem;
+ margin-left: -1rem;
+ width: 3rem;
+ height: 3rem;
+ background: transparent;
+ border-radius: 50%;
+ line-height: 30px;
+ text-align: center;
+ font-weight: bold;
+ padding-top: 0.4rem;
+ box-sizing: border-box;
+ border: 2px solid var(--accent);
+ margin-top: 20px;
+ left: attr(value);
+ color: var(--accent);
+ font-size: 20px;
+
+ &::after {
+ content: "Price";
+ display: block;
+ font-size: 8px;
+ letter-spacing: 0.07em;
+ margin-top: -1rem;
+ }
+
+}
\ No newline at end of file
diff --git a/Parts/Table.js b/Parts/Table.js
index 4368957..bca582f 100644
--- a/Parts/Table.js
+++ b/Parts/Table.js
@@ -1,19 +1,18 @@
import React from "react";
+import tw, {styled} from "twin.macro"
+import 'styled-components/macro'
export function Table(props) {
- return
-
+ return ;
}
-export function TablePart(props) {
- return |
- {props.children}
- | ;
-}
-export function TableHeader(props) {
- return
- {props.children}
- | ;
-}
\ No newline at end of file
+
+
+const TablePart = styled.td(tw`border-t-0 px-6 align-middle border-l-0 border-r-0 text-xs whitespace-nowrap p-4`)
+export {TablePart}
+
+const TableHeader = styled.th(tw`px-6 py-3 align-middle text-xs uppercase whitespace-nowrap font-bold text-left text-secondary border-b-2 border-secondary`)
+export {TableHeader}
diff --git a/Parts/Text.js b/Parts/Text.js
index 9456c3b..4c031e9 100644
--- a/Parts/Text.js
+++ b/Parts/Text.js
@@ -1,40 +1,32 @@
import React from 'react'
+import tw, {styled} from "twin.macro"
+import 'styled-components/macro'
+import { textColors, textColorsHover } from './Colors'
+
function Text() {
return (
-
+
)
}
-export function Divider() {
- return
;
-}
-export function ClickableText({className, ...props}){
- let color = "text-secondary hover:text-primary"
- switch (props.type) {
- case "warning":
- color = "text-accent4 hover:text-accent4-dark"
- break;
- case "danger":
- color = "text-red-700 hover:text-red-800"
- break;
- case "accent":
- color = "text-accent hover:text-accent-dark"
- break;
- case "accent2":
- color = "text-accent2 hover:text-accent2-dark"
- break;
- case "accent3":
- color = "text-accent3 hover:text-accent3-dark"
- break;
- case "accent5":
- color = "text-accent5 hover:btextg-accent5-dark"
- break;
- default:
- break;
- }
- return {props.children}
-}
+
+const Divider = styled.hr(tw`my-2 md:min-w-full border-secondary`)
+export {Divider}
+
+const DividerGreen = styled.hr(tw`h-2 border-0 from-accent bg-gradient-to-r rounded-2xl`)
+export {DividerGreen}
+
+
+
+const ClickableText = styled.button(({ type }) => [
+ // The common button styles added with the tw import
+ tw`text-secondary hover:text-primary font-semibold cursor-pointer`,
+
+ // Use props to conditionally style your components
+ textColors[type], textColorsHover[type]
+ ])
+export {ClickableText}
export default Text
diff --git a/globalStyle.js b/globalStyle.js
new file mode 100644
index 0000000..6c31b73
--- /dev/null
+++ b/globalStyle.js
@@ -0,0 +1,76 @@
+import React, { useState } from 'react'
+import { createGlobalStyle } from 'styled-components'
+import tw, { theme, GlobalStyles as BaseStyles } from 'twin.macro'
+
+const CustomStyles = createGlobalStyle`
+body {
+ -webkit-tap-highlight-color: ${theme`colors.accent`};
+}
+
+:root{
+ --primary: #3d3d3d;
+ --secondary: #535353;
+ --trinary: #2c2c2c;
+
+ --primary-text: #ffffff;
+ --secondary-text: #a0a0a0;
+
+ --primary-invert: #f3f3f3;
+ --secondary-invert: #dbdbdb;
+ --trinary-invert: #ffffff;
+
+ --primary-invert-text: #3d3d3d;
+ --secondary-invert-text: #535353;
+
+ --accent: #00C800;
+ --accent-dark: #008f00;
+ --accent-light: #00ed00;
+ --accent2: #3080FF;
+ --accent2-dark: #225ab4;
+ --accent3: #804000;
+ --accent3-dark: #472400;
+ --accent4: #F8B02C;
+ --accent4-dark: #bd8724;
+ --accent5: #9E3086;
+ --accent5-dark: #6b215b;
+}
+
+.light\-theme{
+ --primary: #f3f3f3;
+ --secondary: #dbdbdb;
+ --trinary: #ffffff;
+ --primary-text: #3d3d3d;
+ --secondary-text: #535353;
+
+
+ --primary-invert: #3d3d3d;
+ --secondary-invert: #535353;
+ --trinary-invert: #2c2c2c;
+ --primary-text-invert: #ffffff;
+ --secondary-text-invert: #a0a0a0;
+}
+
+
+::-webkit-scrollbar {
+ width: 0.5rem;
+}
+::-webkit-scrollbar-track {
+ background: transparent;
+}
+::-webkit-scrollbar-thumb {
+ background: var(--secondary);
+ border-radius: 0.25rem;
+}
+::-webkit-scrollbar-thumb:hover {
+ background: var(--accent-dark);
+}
+`
+
+const GlobalStyles = () => {
+ return <>
+
+
+ >
+}
+
+export default GlobalStyles
\ No newline at end of file