From e8bb4ac0e0c3bc4d4dbe8911f655ff12d6306148 Mon Sep 17 00:00:00 2001 From: Jake Dexheimer Date: Mon, 5 Mar 2018 18:59:53 -0600 Subject: [PATCH] Add button dropdown --- components/Dropdown.js | 23 +++++++++++++++++------ components/svg/Arrowdown.js | 4 ++-- pages/editor.js | 15 +++++---------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/components/Dropdown.js b/components/Dropdown.js index 75526f9..36f553f 100644 --- a/components/Dropdown.js +++ b/components/Dropdown.js @@ -41,7 +41,11 @@ class Dropdown extends React.Component { background: ${COLORS.BLACK}; user-select: none; padding: 8px 16px; - border-bottom: 1px solid ${COLORS.SECONDARY}; + border-bottom: 1px solid ${this.props.color || COLORS.SECONDARY}; + } + + .dropdown-list-item span { + color: ${this.props.color || '#fff'}; } .dropdown-list-item:hover { @@ -58,8 +62,11 @@ class Dropdown extends React.Component { } render() { + const color = this.props.color || COLORS.SECONDARY + // find longest list value in number of characters - const MIN_WIDTH = this.props.list.reduce( + const list = this.props.button ? [...this.props.list, this.props.selected] : this.props.list + const MIN_WIDTH = list.reduce( (max, { name }) => (name && name.length > max ? name.length : max), 0 ) @@ -67,13 +74,13 @@ class Dropdown extends React.Component { return (
{this.props.selected.name}
- +
{this.renderListItems()}
@@ -98,7 +105,7 @@ class Dropdown extends React.Component { .dropdown-display { height: 100%; - border: 1px solid ${COLORS.SECONDARY}; + border: 1px solid ${color}; border-radius: 3px; user-select: none; padding: 8px 16px; @@ -109,6 +116,10 @@ class Dropdown extends React.Component { z-index: 1; } + .dropdown-display span { + color: ${color}; + } + .dropdown-display:hover { background: ${COLORS.HOVER}; } @@ -120,7 +131,7 @@ class Dropdown extends React.Component { .dropdown-list { display: none; margin-top: -1px; - border: 1px solid ${COLORS.SECONDARY}; + border: 1px solid ${color}; border-radius: 0px 0px 3px 3px; max-height: 350px; overflow-y: scroll; diff --git a/components/svg/Arrowdown.js b/components/svg/Arrowdown.js index ba46d99..ea2d560 100644 --- a/components/svg/Arrowdown.js +++ b/components/svg/Arrowdown.js @@ -1,9 +1,9 @@ import React from 'react' -export default () => ( +export default ({ fill }) => ( { const link = document.createElement('a') - link.download = 'carbon.' + format + link.download = `carbon.${format}` link.href = dataUrl document.body.appendChild(link) link.click() @@ -191,16 +190,12 @@ class Editor extends React.Component { color="#57b5f9" style={{ marginRight: '8px' }} /> -