Skip to content

Theme canvas settings #1247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1616232
theme canvas settings
raheeliftikhar5 Oct 8, 2024
420c56f
set default values for canvas settings
raheeliftikhar5 Oct 8, 2024
dba9097
theme canvas settings
raheeliftikhar5 Oct 10, 2024
e76ef90
canvas setting in theme and app
raheeliftikhar5 Oct 10, 2024
81a55be
small fix
raheeliftikhar5 Oct 10, 2024
21ced62
add rowCount in readonly view
raheeliftikhar5 Oct 11, 2024
9c11938
replaced color picker to allow gradient selection
raheeliftikhar5 Oct 15, 2024
c459d56
Timeline: added gradient
raheeliftikhar5 Oct 16, 2024
1c33fd0
added canvas bg color option in app Settings
raheeliftikhar5 Oct 16, 2024
4f19e7b
added background style utility
raheeliftikhar5 Oct 16, 2024
419c11c
ShapeComp: added gradient
raheeliftikhar5 Oct 16, 2024
aba86a6
Containers: added gradient
raheeliftikhar5 Oct 16, 2024
91d8e3a
List/GridView: added gradient
raheeliftikhar5 Oct 16, 2024
f462970
Modal/Drawer: added gradients
raheeliftikhar5 Oct 16, 2024
92292c3
added gradient
raheeliftikhar5 Oct 16, 2024
0d4b64d
Table: added gradient
raheeliftikhar5 Oct 17, 2024
f560a9a
Table: added gradients
raheeliftikhar5 Oct 18, 2024
557407f
fixed canvas settings
raheeliftikhar5 Oct 18, 2024
2f0a51a
set app default canvas settings
raheeliftikhar5 Oct 18, 2024
6c16141
show theme colors in preset colors for color picker
raheeliftikhar5 Oct 21, 2024
b09e024
separate app settings, canvas settings and js settings
raheeliftikhar5 Oct 21, 2024
89aa5d0
move theme selection in color settings
raheeliftikhar5 Oct 22, 2024
bd028f3
fix opacity not working
raheeliftikhar5 Oct 25, 2024
dd50f07
hide gradient selection in color picker for text/border colors
raheeliftikhar5 Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
hide gradient selection in color picker for text/border colors
  • Loading branch information
raheeliftikhar5 committed Oct 25, 2024
commit dd50f07be47b18e006cc316472c0fcb304a1ca20
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface ColorSelectProps {
dispatch?: (value: any) => void;
changeColor?: (value: any) => void;
presetColors?: string[];
allowGradient?: boolean;
}

export const ColorSelect = (props: ColorSelectProps) => {
Expand All @@ -31,9 +32,11 @@ export const ColorSelect = (props: ColorSelectProps) => {

const presetColors = useMemo(() => {
let colors = props.presetColors || [];
colors = colors.concat(gradientColors.slice(0, 16 - colors.length));
if (props.allowGradient) {
colors = colors.concat(gradientColors.slice(0, 16 - colors.length));
}
return colors;
}, [props.presetColors, selectedColor]);
}, [props.presetColors, selectedColor, props.allowGradient]);

const throttleChange = useCallback(
throttle((rgbaColor: string) => {
Expand Down Expand Up @@ -70,6 +73,7 @@ export const ColorSelect = (props: ColorSelectProps) => {
width={250}
height={160}
presets={presetColors}
$allowGradient={props.allowGradient}
/>
</PopoverContainer>
}
Expand Down Expand Up @@ -191,11 +195,14 @@ const ColorBlock = styled.div<{ $color: string }>`
overflow: hidden;
`;

const StyledColorPicker = styled(ColorPicker)`
const StyledColorPicker = styled(ColorPicker)<{$allowGradient?: boolean}>`
#rbgcp-wrapper > div:nth-child(2) > div:first-child > div:first-child {
${props => !props.$allowGradient && `visibility: hidden`};
}
#rbgcp-wrapper > div:last-child > div:last-child {
justify-content: flex-start !important;
gap: 3px;

> div {
border: 1px solid lightgray;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,10 @@ export default function ThemeSettingsSelector(props: ColorConfigProps) {
themeSettingKey !== "gridBgImageOrigin" && (
<div className="config-input">
<ColorSelect
changeColor={_.debounce(setColor, 500, {
leading: true,
trailing: true,
})}
changeColor={setColor}
color={color!}
trigger="hover"
allowGradient={themeSettingKey === 'canvas' || themeSettingKey === 'primarySurface'}
/>
<TacoInput
value={color}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ function AppCanvasSettingsModal(props: ChildrenInstance) {
})}
{gridBg.propertyView({
label: trans("style.background"),
allowGradient: true,
})}
{gridBgImage.propertyView({
label: trans("appSetting.gridBgImage"),
Expand Down
4 changes: 3 additions & 1 deletion client/packages/lowcoder/src/comps/controls/colorControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type PropertyViewParam = {
isDep?: boolean;
// auto-generated message?
depMsg?: string;
allowGradient?: boolean;
};

export class ColorControl extends ColorCodeControl {
Expand All @@ -95,7 +96,7 @@ function ColorItem(props: {
const inputRef = React.createRef<HTMLDivElement>();
const containerRef = React.createRef<HTMLDivElement>();

const currentThemeColors = useThemeColors();
const currentThemeColors = useThemeColors(param.allowGradient);

const input = propertyView.call(controlThis, {
placeholder: param.panelDefaultColor,
Expand Down Expand Up @@ -138,6 +139,7 @@ function ColorItem(props: {
<ColorSelect
dispatch={controlThis.dispatch}
color={param.panelDefaultColor || color || DEFAULT_COLOR}
allowGradient={param.allowGradient}
presetColors={currentThemeColors}
/>
<div style={{ display: "flex" }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
isDep: true,
depMsg:
depMsg,
allowGradient: config.name.includes('background'),
})}
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion client/packages/lowcoder/src/util/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function useMergeCompStyles(
type ColorKey = 'primary' | 'textDark' | 'textLight' | 'canvas' | 'primarySurface' | 'border';
type ColorKeys = ColorKey[];

export function useThemeColors() {
export function useThemeColors(allowGradient?: boolean) {
const currentTheme = useContext(ThemeContext)?.theme ?? {} as ThemeDetail;
const colorKeys: ColorKeys = ['primary', 'textDark', 'textLight', 'canvas', 'primarySurface', 'border'];

Expand All @@ -248,6 +248,9 @@ export function useThemeColors() {
colors.push(currentTheme[colorKey] ?? '');
}
})
if (!allowGradient) {
colors = colors.concat(constantColors);
}
return uniq(colors);
}, [
currentTheme,
Expand Down
12 changes: 12 additions & 0 deletions client/packages/lowcoder/src/util/styleUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ const getBackgroundStyle = (style: Record<string, string | undefined>) => {
`;
}

const getTextStyle = (color?: string) => {
return css`
${isValidColor(color) && `color: ${color};`}
${isValidGradient(color) && `
background-image: -webkit-${color};
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
`}
`;
}

export {
getBackgroundStyle,
getTextStyle,
}
Loading