-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
legend with click event created >relates #7
- Loading branch information
Simon Dupree
committed
Oct 18, 2018
1 parent
b077d49
commit fc5e0e5
Showing
3 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,44 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const colors = ['A1:#ff80cc', 'A3:#9eebcf', 'B1:#96ccff', 'B2:#fbf1a9', 'B8:#ffb700', 'D1:#a463f2', 'D2:#ff6300', 'other:#fff'] | ||
|
||
const createLegend = (open) => { | ||
if (open) { | ||
return colors.map(color => | ||
( | ||
<Circle color={color.split(':')[1]}> | ||
<UseText>{color.split(':')[0]}</UseText> | ||
</Circle> | ||
) | ||
) | ||
} return ( | ||
<Circle color="#ff80cc"> | ||
<UseText>Key</UseText> | ||
</Circle> | ||
) | ||
} | ||
|
||
const LegendUseclass = styled.div.attrs({ | ||
className: "h3 w3 fixed left-1 bottom-1 z-max flex items-center justify-center br-100 bg-black-90" | ||
className: "fixed left-1 bottom-1 z-max" | ||
})``; | ||
|
||
const UseclassText = styled.p.attrs({ | ||
className: "white-100 z-max fw3 flex center " | ||
})`color: white; font-size: 1rem;`; | ||
const Circle = styled.div.attrs({ | ||
className: "mt2 w2 h2 br-100 flex items-center justify-center " | ||
})`background:${props => props.color}` | ||
|
||
const UseText = styled.p.attrs({ | ||
className: "avenir black" | ||
})`` | ||
|
||
const ClassListItems = styled.ul.attrs({ | ||
className: "pl4 list" | ||
})`display:${props => props.display}` | ||
|
||
export default props => ( | ||
<LegendUseclass> <UseclassText>A1</UseclassText> </LegendUseclass> | ||
<LegendUseclass onClick={props.toggleLegend} > | ||
<ClassListItems> | ||
{createLegend(props.legend)} | ||
</ClassListItems> | ||
</LegendUseclass> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters