-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/porter-dev/porter into main
- Loading branch information
Showing
53 changed files
with
3,607 additions
and
1,116 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
type PropsType = { | ||
label?: string, | ||
options: { disabled?: boolean, value: string, label: string }[], | ||
selected: { value: string, label: string }[], | ||
setSelected: (x: { value: string, label: string }[]) => void, | ||
}; | ||
|
||
const CheckboxList = ({ | ||
label, options, selected, setSelected, | ||
}: PropsType) => { | ||
let onSelectOption = (option: { value: string, label: string }) => { | ||
if (!selected.includes(option)) { | ||
selected.push(option); | ||
setSelected(selected); | ||
} else { | ||
selected.splice(selected.indexOf(option), 1); | ||
setSelected(selected); | ||
} | ||
} | ||
|
||
return ( | ||
<StyledCheckboxList> | ||
{label && <Label>{label}</Label>} | ||
{options.map((option: { value: string, label: string }, i: number) => { | ||
return ( | ||
<CheckboxOption | ||
isLast={i === options.length - 1} | ||
onClick={() => onSelectOption(option)} | ||
key={i} | ||
> | ||
<Checkbox checked={selected.includes(option)}> | ||
<i className="material-icons">done</i> | ||
</Checkbox> | ||
{option.label} | ||
</CheckboxOption> | ||
); | ||
})} | ||
</StyledCheckboxList> | ||
); | ||
} | ||
export default CheckboxList; | ||
|
||
const Checkbox = styled.div` | ||
width: 16px; | ||
height: 16px; | ||
border: 1px solid #ffffff55; | ||
margin: 1px 15px 0px 1px; | ||
border-radius: 3px; | ||
background: ${(props: { checked: boolean }) => props.checked ? '#ffffff22' : '#ffffff11'}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
> i { | ||
font-size: 12px; | ||
padding-left: 0px; | ||
display: ${(props: { checked: boolean }) => props.checked ? '' : 'none'}; | ||
} | ||
`; | ||
|
||
const CheckboxOption = styled.div<{ isLast: boolean }>` | ||
width: 100%; | ||
height: 35px; | ||
padding-left: 10px; | ||
display: flex; | ||
cursor: pointer; | ||
align-items: center; | ||
border-bottom: ${props => props.isLast ? '' : '1px solid #ffffff22'}; | ||
font-size: 13px; | ||
:hover { | ||
background: #ffffff18; | ||
} | ||
`; | ||
|
||
const Label = styled.div` | ||
color: #ffffff; | ||
margin-bottom: 10px; | ||
`; | ||
|
||
const StyledCheckboxList = styled.div` | ||
border-radius: 3px; | ||
border: 1px solid #ffffff55; | ||
padding: 0; | ||
background: #ffffff11; | ||
margin-bottom: 15px; | ||
margin-top: 20px; | ||
`; |
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
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
Oops, something went wrong.