Merge pull request #172 from ironcalc/feature/dani-color-picker

UPDATE: Color picker changes
This commit is contained in:
Nicolás Hatcher Andrés
2024-12-08 22:32:14 +01:00
committed by GitHub
2 changed files with 40 additions and 21 deletions

View File

@@ -71,6 +71,7 @@ const ColorPicker = (properties: ColorPickerProps) => {
setColor(newColor); setColor(newColor);
}} }}
/> />
<HorizontalDivider />
<ColorPickerInput> <ColorPickerInput>
<HexWrapper> <HexWrapper>
<HexLabel>{"Hex"}</HexLabel> <HexLabel>{"Hex"}</HexLabel>
@@ -131,6 +132,8 @@ const ColorPicker = (properties: ColorPickerProps) => {
const RecentLabel = styled.div` const RecentLabel = styled.div`
font-family: "Inter"; font-family: "Inter";
font-size: 12px; font-size: 12px;
font-family: Inter;
margin: 8px 8px 0px 8px;
color: ${theme.palette.text.secondary}; color: ${theme.palette.text.secondary};
`; `;
@@ -138,14 +141,17 @@ const ColorList = styled.div`
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
margin: 8px;
justify-content: flex-start;
gap: 4.7px;
`; `;
const Button = styled.button<{ $color: string }>` const Button = styled.button<{ $color: string }>`
width: 20px; width: 16px;
height: 20px; height: 16px;
${({ $color }): string => { ${({ $color }): string => {
if ($color.toUpperCase() === "#FFFFFF") { if ($color.toUpperCase() === "#FFFFFF") {
return `border: 1px solid ${theme.palette.grey["600"]};`; return `border: 1px solid ${theme.palette.grey["300"]};`;
} }
return `border: 1px solid ${$color};`; return `border: 1px solid ${$color};`;
}} }}
@@ -153,17 +159,19 @@ const Button = styled.button<{ $color: string }>`
return $color; return $color;
}}; }};
box-sizing: border-box; box-sizing: border-box;
margin-top: 10px; margin-top: 0px;
margin-right: 10px; border-radius: 4px;
border-radius: 2px; &:hover {
cursor: pointer;
outline: 1px solid ${theme.palette.grey["300"]};
outline-offset: 1px;
}
`; `;
const HorizontalDivider = styled.div` const HorizontalDivider = styled.div`
height: 0px; height: 0px;
width: 100%; width: 100%;
border-top: 1px solid ${theme.palette.grey["400"]}; border-top: 1px solid ${theme.palette.grey["200"]};
margin-top: 15px;
margin-bottom: 5px;
`; `;
// const StyledPopover = styled(Popover)` // const StyledPopover = styled(Popover)`
@@ -183,7 +191,7 @@ const HorizontalDivider = styled.div`
const ColorPickerDialog = styled.div` const ColorPickerDialog = styled.div`
background: ${theme.palette.background.default}; background: ${theme.palette.background.default};
width: ${colorPickerWidth}px; width: ${colorPickerWidth}px;
padding: 15px; padding: 0px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -193,11 +201,11 @@ const ColorPickerDialog = styled.div`
} }
& .react-colorful__saturation { & .react-colorful__saturation {
border-bottom: none; border-bottom: none;
border-radius: 5px; border-radius: 0px;
} }
& .react-colorful__hue { & .react-colorful__hue {
height: 20px; height: 8px;
margin-top: 15px; margin: 8px;
border-radius: 5px; border-radius: 5px;
} }
& .react-colorful__saturation-pointer { & .react-colorful__saturation-pointer {
@@ -206,19 +214,22 @@ const ColorPickerDialog = styled.div`
} }
& .react-colorful__hue-pointer { & .react-colorful__hue-pointer {
width: 7px; width: 7px;
border-radius: 3px; border-radius: 8px;
height: 16px;
width: 16px;
border-bottom: 1px solid #eee;
} }
`; `;
const HashLabel = styled.div` const HashLabel = styled.div`
margin: auto 0px auto 10px; margin: auto 0px auto 10px;
font-size: 13px; font-size: 13px;
color: #7d8ec2; color: #333;
font-family: ${theme.typography.button.fontFamily}; font-family: ${theme.typography.button.fontFamily};
`; `;
const HexLabel = styled.div` const HexLabel = styled.div`
margin: auto 10px auto 0px; margin: auto 0px;
font-size: 12px; font-size: 12px;
display: inline-flex; display: inline-flex;
font-family: ${theme.typography.button.fontFamily}; font-family: ${theme.typography.button.fontFamily};
@@ -227,15 +238,22 @@ const HexLabel = styled.div`
const HexColorInputBox = styled.div` const HexColorInputBox = styled.div`
display: inline-flex; display: inline-flex;
flex-grow: 1; flex-grow: 1;
margin-right: 10px;
width: 140px; width: 140px;
height: 28px; height: 28px;
border: 1px solid ${theme.palette.grey["600"]}; border: 1px solid ${theme.palette.grey["300"]};
border-radius: 5px; border-radius: 5px;
&:hover {
border: 1px solid ${theme.palette.grey["600"]};
}
&:focus-within {
outline: 2px solid ${theme.palette.secondary.main};
outline-offset: 1px;
}
`; `;
const HexWrapper = styled.div` const HexWrapper = styled.div`
display: flex; display: flex;
gap: 8px;
flex-grow: 1; flex-grow: 1;
& input { & input {
min-width: 0px; min-width: 0px;
@@ -259,7 +277,7 @@ const Swatch = styled.div<{ $color: string }>`
display: inline-flex; display: inline-flex;
${({ $color }): string => { ${({ $color }): string => {
if ($color.toUpperCase() === "#FFFFFF") { if ($color.toUpperCase() === "#FFFFFF") {
return `border: 1px solid ${theme.palette.grey["600"]};`; return `border: 1px solid ${theme.palette.grey["300"]};`;
} }
return `border: 1px solid ${$color};`; return `border: 1px solid ${$color};`;
}} }}
@@ -273,7 +291,8 @@ const ColorPickerInput = styled.div`
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin-top: 15px; margin: 8px;
gap: 8px;
`; `;
export default ColorPicker; export default ColorPicker;

View File

@@ -530,7 +530,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
); );
setRedrawId((id) => id + 1); setRedrawId((id) => id + 1);
}} }}
fillColor={style.fill.fg_color || "#FFF"} fillColor={style.fill.fg_color || "#FFFFFF"}
fontColor={style.font.color} fontColor={style.font.color}
bold={style.font.b} bold={style.font.b}
underline={style.font.u} underline={style.font.u}