+
onSelected(title)}>
{title}
)
}
diff --git a/gm-dash/ui/src/components/Card/Card.css b/gm-dash/ui/src/components/Card/Card.css
index bbdf4dd..51c70fb 100644
--- a/gm-dash/ui/src/components/Card/Card.css
+++ b/gm-dash/ui/src/components/Card/Card.css
@@ -11,6 +11,5 @@
}
.card__body {
- display: flex;
}
diff --git a/gm-dash/ui/src/components/Selector/Selector.css b/gm-dash/ui/src/components/Selector/Selector.css
new file mode 100644
index 0000000..e69de29
diff --git a/gm-dash/ui/src/components/Selector/Selector.tsx b/gm-dash/ui/src/components/Selector/Selector.tsx
new file mode 100644
index 0000000..ecbce9d
--- /dev/null
+++ b/gm-dash/ui/src/components/Selector/Selector.tsx
@@ -0,0 +1,36 @@
+import React from 'react';
+import Activator, { ActivatorProps } from '../Activator/Activator';
+
+export interface Selectable {
+ onSelected?: (key: string) => void;
+}
+
+interface SelectorProps {
+ options: Array
;
+ exclusive: boolean;
+}
+
+const exclusiveSelect = (state: { [key: string]: boolean }, targetId: string) => {
+ console.log("running exclusiveSelect on ", targetId);
+ return { [targetId]: true };
+}
+
+const multiSelect = (state: { [key: string]: boolean }, targetId: string) => {
+ if (state[targetId]) {
+ return { ...state, [targetId]: false };
+ } else {
+ return { ...state, [targetId]: true };
+ }
+}
+
+const Selector = ({ options, exclusive }: SelectorProps) => {
+ const [selected, dispatch] = React.useReducer(exclusive ? exclusiveSelect : multiSelect, {});
+
+ let tiedOptions = options.map(option =>
+ dispatch(key)} activated={selected[option.title]} />
+ );
+
+ return ( {tiedOptions}
)
+}
+
+export default Selector;