diff --git a/client/src/assets/components/_sensors-page.scss b/client/src/assets/components/_sensors-page.scss index ae276b6..0f12ae8 100644 --- a/client/src/assets/components/_sensors-page.scss +++ b/client/src/assets/components/_sensors-page.scss @@ -1,33 +1,41 @@ .sensors-page { - .sensors-head { - display: flex; - align-items: center; - flex: 1; + .sensors-head { + display: flex; + align-items: center; + flex: 1; - > button { - margin-left: auto; - } - } + > button { + margin-left: auto; + } + } section.content { - padding: 1rem; - - > .box { - max-width: 50rem; - padding: 1rem; - overflow: auto; - } - .sensors-list { - .sensor-item { - display: flex; - align-items: center; - margin: 0.25rem 0; + display: grid; + grid-template-columns: repeat(6, 1fr); + overflow: auto; + padding: 1rem; - &.head { - opacity: 0.75; - font-size: 85%; - } + @media screen and (max-width: 1500px) { + grid-template-columns: repeat(4, 1fr); + } + + @media screen and (max-width: 1200px) { + grid-template-columns: repeat(3, 1fr); + } + + @media screen and (max-width: 900px) { + grid-template-columns: repeat(2, 1fr); + } + + @media screen and (max-width: 768px) { + grid-template-columns: repeat(1, 1fr); + } + + .sensor-item { + margin: 0.25rem; + overflow: auto; + padding: 0.5rem; > div { flex-grow: 0; @@ -36,30 +44,46 @@ text-overflow: ellipsis; } - > .id { - flex: 0.3; - margin-right: 0.5rem; - } + > .auth { + .auth-value { + display: flex; + align-items: center; + font-size: 85%; + margin: 0.25rem 0; - > .name { - margin-right: 0.5rem; - flex: 1; - } + .label { + width: 2rem; + background-color: #666; + padding: 0.2rem; + border-radius: 0.25rem; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } - > .key { - display: flex; - flex: 1.5; + .value { + flex: 1; + display: flex; - button { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - padding: 0.25rem 0.5rem; + input { + flex: 1; + border-radius: 0; + } + + button { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + padding: 0rem 0.5rem; + flex-grow: 0; + flex-shrink: 0; + font-size: 120%; + } + } } } > .actions { - flex: 2; text-align: right; + margin-top: 0.5rem; button { margin-left: 0.25rem; @@ -69,3 +93,29 @@ } } } + +/* +@media screen and (max-width: 768px) { + .sensors-page .sensors-list { + grid-template-columns: repeat(1, 1fr); + } +} + +@media screen and (max-width: 900px) { + .sensors-page .sensors-list { + grid-template-columns: repeat(2, 1fr); + } +} + +@media screen and (max-width: 1200px) { + .sensors-page .sensors-list { + grid-template-columns: repeat(3, 1fr); + } +} + +@media screen and (max-width: 1980px) { + .sensors-page .sensors-list { + grid-template-columns: repeat(4, 1fr); + } +} +*/ diff --git a/client/src/assets/icons/clipboard-check.svg b/client/src/assets/icons/clipboard-check.svg new file mode 100644 index 0000000..918b928 --- /dev/null +++ b/client/src/assets/icons/clipboard-check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/assets/icons/clipboard-copy.svg b/client/src/assets/icons/clipboard-copy.svg new file mode 100644 index 0000000..6b701b3 --- /dev/null +++ b/client/src/assets/icons/clipboard-copy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/components/InputWithCopy.tsx b/client/src/components/InputWithCopy.tsx new file mode 100644 index 0000000..f84fb59 --- /dev/null +++ b/client/src/components/InputWithCopy.tsx @@ -0,0 +1,36 @@ +import { ClipboardCheckIcon, ClipboardCopyIcon } from '@/icons' +import { useRef, useState } from 'preact/hooks' + +type Props = { + value: string +} + +export const InputWithCopy = ({ value }: Props) => { + const inputRef = useRef(null) + + const [hasCopied, setHasCopied] = useState(false) + + const handleCopy = () => { + const target = inputRef.current + + if (target) { + target.select() + target.setSelectionRange(0, 99999) + + navigator.clipboard.writeText(target.value) + + setHasCopied(true) + + setTimeout(() => setHasCopied(false), 2000) + } + } + + return ( + <> + + + + ) +} diff --git a/client/src/icons.ts b/client/src/icons.ts index f6383b2..967879f 100644 --- a/client/src/icons.ts +++ b/client/src/icons.ts @@ -7,3 +7,5 @@ export { ReactComponent as PlusIcon } from '@/assets/icons/plus.svg' export { ReactComponent as EyeIcon } from '@/assets/icons/eye.svg' export { ReactComponent as EyeOffIcon } from '@/assets/icons/eye-off.svg' export { ReactComponent as EditIcon } from '@/assets/icons/edit.svg' +export { ReactComponent as ClipboardCopyIcon } from '@/assets/icons/clipboard-copy.svg' +export { ReactComponent as ClipboardCheckIcon } from '@/assets/icons/clipboard-check.svg' diff --git a/client/src/pages/sensors/SensorsPage.tsx b/client/src/pages/sensors/SensorsPage.tsx index 40b0790..44acade 100644 --- a/client/src/pages/sensors/SensorsPage.tsx +++ b/client/src/pages/sensors/SensorsPage.tsx @@ -24,18 +24,10 @@ export const SensorsPage = () => { } className="sensors-page" > -
-
-
-
ID
-
Name
-
Key
-
-
- {sensors.data?.map((i) => ( - - ))} -
+
+ {sensors.data?.map((i) => ( + + ))}
{(showNew || edited) && ( { - const [showPassword, setShowPassword] = useState(false) - return ( -
-
{sensor.id}
+
{sensor.name}
-
- - + +
+
+
ID
+
+ +
+
+
+
KEY
+
+ +
+
- +