From cf013cc342f391be2cf836b97c99597f28abc476 Mon Sep 17 00:00:00 2001 From: Ari Date: Mon, 16 May 2022 19:25:50 -0400 Subject: [PATCH] fixed up styles --- .../AutomationList/AutomationListBox.css | 41 +++++++++++++------ .../AutomationListBox.stories.tsx | 8 ++-- .../AutomationList/AutomationListBox.tsx | 17 ++++---- .../src/components/AutomationList/index.tsx | 1 + webapp/src/styles/theme.ts | 4 +- 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/webapp/src/components/AutomationList/AutomationListBox.css b/webapp/src/components/AutomationList/AutomationListBox.css index fb1bb76..29124b3 100644 --- a/webapp/src/components/AutomationList/AutomationListBox.css +++ b/webapp/src/components/AutomationList/AutomationListBox.css @@ -10,10 +10,12 @@ flex: 1; user-select: none; } -.automation-list-box--body > * { + +.automation-list-box--body>* { padding-top: 0.5em; padding-bottom: 0.5em; } + .automation-list-box--body--group { display: flex; flex-direction: column; @@ -21,33 +23,37 @@ border-radius: 10px; padding-bottom: 0.5em; border-width: 1px; - border-bottom-style: solid ; + border-bottom-style: solid; border-color: white; } -.automation-list-box--body--group > .automation-list-box--body--group { - border-left-style: solid ; + +.automation-list-box--body--group>.automation-list-box--body--group { + border-left-style: solid; border-top-left-radius: 0; margin-left: 0.75em; padding-left: 0.5em; } -.automation-list-box--body--group > b { +.automation-list-box--body--group>b { width: 100%; cursor: pointer; padding: 0.1em; } -.automation-list-box--body--group > b:hover { + +.automation-list-box--body--group>b:hover { background-color: var(--secondary-accent); color: var(--secondary); } -.automation-list-box--body--item:hover { +.automation-list-box--body--item:hover, .automation-list-box--body--item.selected { background-color: var(--primary-accent); color: var(--primary); } -.automation-list-box--body--item:hover > .automation-list-box--body--item--tags > span { + +.automation-list-box--body--item:hover>.automation-list-box--body--item--tags>span { border-color: var(--primary); } + .automation-list-box--body--item { padding-left: 1em; cursor: pointer; @@ -57,25 +63,31 @@ gap: 1em; flex-wrap: wrap; } + .automation-list-box--body--item::before { content: "⊚ "; } + .automation-list-box--body--item--title { display: flex; flex-direction: column; padding-left: 0.25em; flex: 1; } -.automation-list-box--body--item--title > b { + +.automation-list-box--body--item--title>b { font-size: 1em; } -.automation-list-box--body--item--title > span, .automation-list-box--body--item--title > b > span { + +.automation-list-box--body--item--title>span, .automation-list-box--body--item--title>b>span { font-size: 0.75em; } -.automation-list-box--body--item > button { + +.automation-list-box--body--item>button { padding: 0.25em !important; margin: 0.5em !important; } + .automation-list-box--body--item--tags { flex: 1; display: flex; @@ -87,13 +99,15 @@ max-height: 100%; gap: 0.25em; } -.automation-list-box--body--item--tags > span { + +.automation-list-box--body--item--tags>span { border-color: var(--primary-accent); border-style: solid; border-width: 1px; border-radius: 0.5em; padding: 0.1em 0.5em; } + .automation-list-box--bottom { margin-top: 0.5em; margin-bottom: 0.5em; @@ -102,7 +116,8 @@ justify-content: space-around; align-items: center; } -.automation-list-box--bottom > button { + +.automation-list-box--bottom>button { background-color: #070; color: var(--primary-accent); padding: 0.5em 2em; diff --git a/webapp/src/components/AutomationList/AutomationListBox.stories.tsx b/webapp/src/components/AutomationList/AutomationListBox.stories.tsx index 8186781..c0428b7 100644 --- a/webapp/src/components/AutomationList/AutomationListBox.stories.tsx +++ b/webapp/src/components/AutomationList/AutomationListBox.stories.tsx @@ -13,10 +13,12 @@ export default { const Template: ComponentStory = args => { - const [autos, setAutos] = useState(args.automations) - console.log({ args }) + const [selected, setSelected] = useState(args.selected) return
- + { + setSelected(i) + args.onSelectAutomation(i) + }} />
} diff --git a/webapp/src/components/AutomationList/AutomationListBox.tsx b/webapp/src/components/AutomationList/AutomationListBox.tsx index 08b635f..185bcb8 100644 --- a/webapp/src/components/AutomationList/AutomationListBox.tsx +++ b/webapp/src/components/AutomationList/AutomationListBox.tsx @@ -9,6 +9,7 @@ import { TrashIcon } from "components/Icons"; export type Props = { automations: AutomationData[]; + selected: number; onSelectAutomation: (i: number) => void; onRemove: (i: number) => void; onAdd: () => void; @@ -16,6 +17,7 @@ export type Props = { export const AutomationListBox: FC = ({ automations, + selected, onSelectAutomation, onAdd, onRemove, @@ -23,9 +25,9 @@ export const AutomationListBox: FC = ({ const tags = getTagList(automations); const [searchText, setSearchText] = useState(''); - const [selected, setSelected] = useState([]); - const filteredAutomations = filterAutomations(automations, searchText, selected, tags); - const groups = groupAutomations(filteredAutomations.map(([a, _]) => a), selected, tags); + const [selectedTagIdx, setSelectedTagIdx] = useState([]); + const filteredAutomations = filterAutomations(automations, searchText, selectedTagIdx, tags); + const groups = groupAutomations(filteredAutomations.map(([a, _]) => a), selectedTagIdx, tags); return
@@ -36,14 +38,14 @@ export const AutomationListBox: FC = ({ />
- {convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove)} + {convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove, selected)}
@@ -123,13 +125,14 @@ const convertGroupsToItems = ( autos: Array<[AutomationData, number]>, onSelectAutomation: (i: number) => void, onRemove: (i: number) => void, + selected: number, ) => { if (Array.isArray(groups)) { return groups.map(i => { const [auto, autoIndex] = autos[i]; return
onSelectAutomation(autoIndex)} > diff --git a/webapp/src/components/AutomationList/index.tsx b/webapp/src/components/AutomationList/index.tsx index 6a763aa..8586201 100644 --- a/webapp/src/components/AutomationList/index.tsx +++ b/webapp/src/components/AutomationList/index.tsx @@ -42,6 +42,7 @@ export const AutomationList: FC = ({ setCurrent(automations.length) }} onSelectAutomation={setCurrent} + selected={current} onRemove={onRemove} />