Update select component

This commit is contained in:
Hazem Krimi
2021-04-23 18:24:51 +01:00
parent dc4cbbb528
commit d633a519eb
2 changed files with 29 additions and 96 deletions
+5 -1
View File
@@ -49,12 +49,16 @@ const Select = ({
)} )}
</div> </div>
<div className='select'> <div className='select'>
<div>
<select value={value} name={name} onChange={onChange}> <select value={value} name={name} onChange={onChange}>
{options.map((option) => ( {options.map((option) => (
<option value={option.value}>{option.label}</option> <option key={value} value={option.value}>
{option.label}
</option>
))} ))}
</select> </select>
</div> </div>
</div>
</Wrapper> </Wrapper>
); );
}; };
+17 -88
View File
@@ -24,35 +24,23 @@ export const Wrapper = styled.div<WrapperProps>`
width: inherit; width: inherit;
height: inherit; height: inherit;
border-radius: 5px; border-radius: 5px;
padding: 1rem; padding: 2px;
position: relative;
color: ${({ theme }) => theme.colors.black.main}; color: ${({ theme }) => theme.colors.black.main};
div {
background: ${({ theme }) => theme.colors.white.main}; background: ${({ theme }) => theme.colors.white.main};
background-clip: padding-box; padding: 1rem;
border: 2px solid transparent; border-radius: 5px;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
&:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: inherit;
height: inherit;
z-index: -1;
margin: -2px;
border-radius: inherit;
} }
} }
.info { .info {
margin-bottom: 5px; margin-bottom: 5px;
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: 1fr auto;
align-items: center; align-items: center;
p { p {
@@ -78,117 +66,67 @@ export const Wrapper = styled.div<WrapperProps>`
background-image: url('../../assets/icons/chevron-down.svg'); background-image: url('../../assets/icons/chevron-down.svg');
} }
.icon {
cursor: pointer;
display: inline-flex;
align-items: center;
}
.icon.left {
margin-right: 0.5rem;
}
${({ color, theme }) => { ${({ color, theme }) => {
switch (color) { switch (color) {
case 'client': case 'client':
return css` return css`
.select:before { .select {
background: ${theme.colors.client.light}; background: ${theme.colors.client.light};
} }
.icon svg path {
stroke: ${theme.colors.client.main};
}
`; `;
case 'productOwner': case 'productOwner':
return css` return css`
.select:before { .select {
background: ${theme.colors.productOwner.light}; background: ${theme.colors.productOwner.light};
} }
.icon svg path {
stroke: ${theme.colors.productOwner.main};
}
`; `;
case 'developer': case 'developer':
return css` return css`
.select:before { .select {
background: ${theme.colors.developer.light}; background: ${theme.colors.developer.light};
} }
.icon svg path {
stroke: ${theme.colors.developer.main};
}
`; `;
case 'admin': case 'admin':
return css` return css`
.select:before { .select {
background: ${theme.colors.admin.light}; background: ${theme.colors.admin.light};
} }
.icon svg path {
stroke: ${theme.colors.admin.main};
}
`; `;
case 'success': case 'success':
return css` return css`
.select:before { .select {
background: ${theme.colors.success.main}; background: ${theme.colors.success.main};
} }
.icon svg path {
stroke: ${theme.colors.success.main};
}
`; `;
case 'warning': case 'warning':
return css` return css`
.select:before { .select {
background: ${theme.colors.warning.main}; background: ${theme.colors.warning.main};
} }
.icon svg path {
stroke: ${theme.colors.warning.main};
}
`; `;
case 'error': case 'error':
return css` return css`
.select:before { .select {
background: ${theme.colors.error.main}; background: ${theme.colors.error.main};
} }
.icon svg path {
stroke: ${theme.colors.error.main};
}
`; `;
case 'black': case 'black':
return css` return css`
.select:before { .select {
background: ${theme.colors.black.main}; background: ${theme.colors.black.main};
} }
.icon svg path {
stroke: ${theme.colors.black.main};
}
`; `;
case 'white': case 'white':
return css` return css`
.select:before { .select {
background: ${theme.colors.white.main}; background: ${theme.colors.white.main};
} }
.icon svg path {
stroke: ${theme.colors.white.main};
}
`; `;
default: default:
return css` return css`
.select:before { .select {
background: ${theme.colors.client.light}; background: ${theme.colors.client.light};
} }
.icon svg path {
stroke: ${theme.colors.client.main};
}
`; `;
} }
}} }}
@@ -202,13 +140,9 @@ export const Wrapper = styled.div<WrapperProps>`
-webkit-text-fill-color: transparent; -webkit-text-fill-color: transparent;
} }
.select:before { .select {
background: ${theme.colors.error.main}; background: ${theme.colors.error.main};
} }
.icon svg path {
stroke: ${theme.colors.error.main};
}
`} `}
${({ fullWidth }) => ${({ fullWidth }) =>
@@ -216,10 +150,5 @@ export const Wrapper = styled.div<WrapperProps>`
css` css`
width: 100%; width: 100%;
font-size: 1.25rem; font-size: 1.25rem;
.icon svg {
width: 1.25rem;
height: 1.25rem;
}
`}; `};
`; `;