fixed global styles redundancy
This commit is contained in:
parent
a31af13c84
commit
fcc3d9e868
@ -461,10 +461,6 @@ export function ElementEditorPanel({
|
|||||||
descriptionTextColor={
|
descriptionTextColor={
|
||||||
selectedElement.descriptionTextColor || '#4B5563'
|
selectedElement.descriptionTextColor || '#4B5563'
|
||||||
}
|
}
|
||||||
descriptionBackgroundColor={
|
|
||||||
selectedElement.descriptionBackgroundColor ||
|
|
||||||
'transparent'
|
|
||||||
}
|
|
||||||
iconAssetOptions={iconAssetOptions}
|
iconAssetOptions={iconAssetOptions}
|
||||||
onChange={(prop, value) =>
|
onChange={(prop, value) =>
|
||||||
onUpdateElement({ [prop]: value })
|
onUpdateElement({ [prop]: value })
|
||||||
@ -611,8 +607,6 @@ export function ElementEditorPanel({
|
|||||||
zIndex: selectedElement.zIndex || '',
|
zIndex: selectedElement.zIndex || '',
|
||||||
backgroundColor: selectedElement.backgroundColor || '',
|
backgroundColor: selectedElement.backgroundColor || '',
|
||||||
color: selectedElement.color || '',
|
color: selectedElement.color || '',
|
||||||
fontFamily: selectedElement.fontFamily || '',
|
|
||||||
fontStretch: selectedElement.fontStretch || '',
|
|
||||||
}}
|
}}
|
||||||
onChange={(prop, value) =>
|
onChange={(prop, value) =>
|
||||||
handleCssPropertyChange(prop, value, onUpdateElement)
|
handleCssPropertyChange(prop, value, onUpdateElement)
|
||||||
|
|||||||
@ -19,7 +19,6 @@ const DescriptionSettingsSection: React.FC<DescriptionSettingsSectionProps> = ({
|
|||||||
descriptionTextFontFamily,
|
descriptionTextFontFamily,
|
||||||
descriptionTitleColor,
|
descriptionTitleColor,
|
||||||
descriptionTextColor,
|
descriptionTextColor,
|
||||||
descriptionBackgroundColor,
|
|
||||||
onChange,
|
onChange,
|
||||||
context,
|
context,
|
||||||
iconAssetOptions = [],
|
iconAssetOptions = [],
|
||||||
@ -135,15 +134,6 @@ const DescriptionSettingsSection: React.FC<DescriptionSettingsSectionProps> = ({
|
|||||||
className='h-10 w-full'
|
className='h-10 w-full'
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormField label='Background color'>
|
|
||||||
<input
|
|
||||||
value={descriptionBackgroundColor}
|
|
||||||
onChange={(event) =>
|
|
||||||
onChange('descriptionBackgroundColor', event.target.value)
|
|
||||||
}
|
|
||||||
placeholder='e.g. transparent, #ffffff'
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -20,7 +20,6 @@ interface DescriptionSettingsSectionCompactProps {
|
|||||||
descriptionTextFontFamily: string;
|
descriptionTextFontFamily: string;
|
||||||
descriptionTitleColor: string;
|
descriptionTitleColor: string;
|
||||||
descriptionTextColor: string;
|
descriptionTextColor: string;
|
||||||
descriptionBackgroundColor: string;
|
|
||||||
iconAssetOptions: AssetOption[];
|
iconAssetOptions: AssetOption[];
|
||||||
onChange: (prop: string, value: string) => void;
|
onChange: (prop: string, value: string) => void;
|
||||||
}
|
}
|
||||||
@ -37,7 +36,6 @@ const DescriptionSettingsSectionCompact: React.FC<
|
|||||||
descriptionTextFontFamily,
|
descriptionTextFontFamily,
|
||||||
descriptionTitleColor,
|
descriptionTitleColor,
|
||||||
descriptionTextColor,
|
descriptionTextColor,
|
||||||
descriptionBackgroundColor,
|
|
||||||
iconAssetOptions,
|
iconAssetOptions,
|
||||||
onChange,
|
onChange,
|
||||||
}) => {
|
}) => {
|
||||||
@ -183,20 +181,6 @@ const DescriptionSettingsSectionCompact: React.FC<
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className='mb-1 block text-[11px] font-semibold text-gray-600'>
|
|
||||||
Background color
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
className='w-full rounded border border-gray-300 px-2 py-1 text-xs'
|
|
||||||
value={descriptionBackgroundColor}
|
|
||||||
onChange={(event) =>
|
|
||||||
onChange('descriptionBackgroundColor', event.target.value)
|
|
||||||
}
|
|
||||||
placeholder='e.g. transparent, #ffffff, rgba(0,0,0,0.5)'
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import FormField from '../FormField';
|
import FormField from '../FormField';
|
||||||
import type { StyleSettingsSectionProps } from './types';
|
import type { StyleSettingsSectionProps } from './types';
|
||||||
import { FONT_OPTIONS, getFontByKey, getFontKeyFromValues } from '../../lib/fonts';
|
|
||||||
|
|
||||||
const StyleSettingsSection: React.FC<StyleSettingsSectionProps> = ({
|
const StyleSettingsSection: React.FC<StyleSettingsSectionProps> = ({
|
||||||
values,
|
values,
|
||||||
@ -241,31 +240,6 @@ const StyleSettingsSection: React.FC<StyleSettingsSectionProps> = ({
|
|||||||
placeholder='e.g. #131C22 / inherit'
|
placeholder='e.g. #131C22 / inherit'
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormField label='Font family'>
|
|
||||||
<select
|
|
||||||
value={getFontKeyFromValues(values.fontFamily, values.fontStretch)}
|
|
||||||
onChange={(event) => {
|
|
||||||
const fontKey = event.target.value;
|
|
||||||
if (!fontKey) {
|
|
||||||
onChange('fontFamily', '');
|
|
||||||
onChange('fontStretch', '');
|
|
||||||
} else {
|
|
||||||
const font = getFontByKey(fontKey);
|
|
||||||
if (font) {
|
|
||||||
onChange('fontFamily', font.fontFamily);
|
|
||||||
onChange('fontStretch', font.fontStretch || '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value=''>Not set</option>
|
|
||||||
{FONT_OPTIONS.map((font) => (
|
|
||||||
<option key={font.key} value={font.key}>
|
|
||||||
{font.label}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</FormField>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { StyleSettingsSectionProps } from './types';
|
import type { StyleSettingsSectionProps } from './types';
|
||||||
import { FONT_OPTIONS, getFontByKey, getFontKeyFromValues } from '../../lib/fonts';
|
|
||||||
|
|
||||||
const StyleSettingsSectionCompact: React.FC<StyleSettingsSectionProps> = ({
|
const StyleSettingsSectionCompact: React.FC<StyleSettingsSectionProps> = ({
|
||||||
values,
|
values,
|
||||||
@ -337,36 +336,6 @@ const StyleSettingsSectionCompact: React.FC<StyleSettingsSectionProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className='mb-1 block text-[11px] font-semibold text-gray-600'>
|
|
||||||
Font family
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
className='w-full rounded border border-gray-300 px-2 py-1 text-xs'
|
|
||||||
value={getFontKeyFromValues(values.fontFamily, values.fontStretch)}
|
|
||||||
onChange={(e) => {
|
|
||||||
const fontKey = e.target.value;
|
|
||||||
if (!fontKey) {
|
|
||||||
onChange('fontFamily', '');
|
|
||||||
onChange('fontStretch', '');
|
|
||||||
} else {
|
|
||||||
const font = getFontByKey(fontKey);
|
|
||||||
if (font) {
|
|
||||||
onChange('fontFamily', font.fontFamily);
|
|
||||||
onChange('fontStretch', font.fontStretch || '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value=''>Not set</option>
|
|
||||||
{FONT_OPTIONS.map((font) => (
|
|
||||||
<option key={font.key} value={font.key}>
|
|
||||||
{font.label}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -125,7 +125,6 @@ export interface DescriptionSettingsSectionProps {
|
|||||||
descriptionTextFontFamily: string;
|
descriptionTextFontFamily: string;
|
||||||
descriptionTitleColor: string;
|
descriptionTitleColor: string;
|
||||||
descriptionTextColor: string;
|
descriptionTextColor: string;
|
||||||
descriptionBackgroundColor: string;
|
|
||||||
onChange: (field: string, value: string) => void;
|
onChange: (field: string, value: string) => void;
|
||||||
context: ElementSettingsContext;
|
context: ElementSettingsContext;
|
||||||
iconAssetOptions?: AssetOption[];
|
iconAssetOptions?: AssetOption[];
|
||||||
|
|||||||
@ -68,7 +68,6 @@ interface FormState {
|
|||||||
zIndex: string;
|
zIndex: string;
|
||||||
backgroundColor: string;
|
backgroundColor: string;
|
||||||
color: string;
|
color: string;
|
||||||
fontFamily: string;
|
|
||||||
|
|
||||||
// Effect settings
|
// Effect settings
|
||||||
appearAnimation: string;
|
appearAnimation: string;
|
||||||
@ -115,7 +114,6 @@ interface FormState {
|
|||||||
descriptionTextFontFamily: string;
|
descriptionTextFontFamily: string;
|
||||||
descriptionTitleColor: string;
|
descriptionTitleColor: string;
|
||||||
descriptionTextColor: string;
|
descriptionTextColor: string;
|
||||||
descriptionBackgroundColor: string;
|
|
||||||
|
|
||||||
// Media settings
|
// Media settings
|
||||||
mediaUrl: string;
|
mediaUrl: string;
|
||||||
@ -167,7 +165,6 @@ const initialState: FormState = {
|
|||||||
zIndex: '',
|
zIndex: '',
|
||||||
backgroundColor: '',
|
backgroundColor: '',
|
||||||
color: '',
|
color: '',
|
||||||
fontFamily: '',
|
|
||||||
// Effect settings
|
// Effect settings
|
||||||
appearAnimation: '',
|
appearAnimation: '',
|
||||||
appearAnimationDuration: '',
|
appearAnimationDuration: '',
|
||||||
@ -207,7 +204,6 @@ const initialState: FormState = {
|
|||||||
descriptionTextFontFamily: '',
|
descriptionTextFontFamily: '',
|
||||||
descriptionTitleColor: '',
|
descriptionTitleColor: '',
|
||||||
descriptionTextColor: '',
|
descriptionTextColor: '',
|
||||||
descriptionBackgroundColor: '',
|
|
||||||
mediaUrl: '',
|
mediaUrl: '',
|
||||||
mediaAutoplay: false,
|
mediaAutoplay: false,
|
||||||
mediaLoop: false,
|
mediaLoop: false,
|
||||||
@ -271,7 +267,6 @@ export function useElementSettingsForm(options: UseElementSettingsFormOptions) {
|
|||||||
zIndex: String(settings.zIndex || ''),
|
zIndex: String(settings.zIndex || ''),
|
||||||
backgroundColor: String(settings.backgroundColor || ''),
|
backgroundColor: String(settings.backgroundColor || ''),
|
||||||
color: String(settings.color || ''),
|
color: String(settings.color || ''),
|
||||||
fontFamily: String(settings.fontFamily || ''),
|
|
||||||
// Effect settings
|
// Effect settings
|
||||||
appearAnimation: String(settings.appearAnimation || ''),
|
appearAnimation: String(settings.appearAnimation || ''),
|
||||||
appearAnimationDuration: String(settings.appearAnimationDuration || ''),
|
appearAnimationDuration: String(settings.appearAnimationDuration || ''),
|
||||||
@ -326,9 +321,6 @@ export function useElementSettingsForm(options: UseElementSettingsFormOptions) {
|
|||||||
),
|
),
|
||||||
descriptionTitleColor: String(settings.descriptionTitleColor || ''),
|
descriptionTitleColor: String(settings.descriptionTitleColor || ''),
|
||||||
descriptionTextColor: String(settings.descriptionTextColor || ''),
|
descriptionTextColor: String(settings.descriptionTextColor || ''),
|
||||||
descriptionBackgroundColor: String(
|
|
||||||
settings.descriptionBackgroundColor || '',
|
|
||||||
),
|
|
||||||
mediaUrl: String(settings.mediaUrl || ''),
|
mediaUrl: String(settings.mediaUrl || ''),
|
||||||
mediaAutoplay: Boolean(settings.mediaAutoplay),
|
mediaAutoplay: Boolean(settings.mediaAutoplay),
|
||||||
mediaLoop: Boolean(settings.mediaLoop),
|
mediaLoop: Boolean(settings.mediaLoop),
|
||||||
@ -408,7 +400,6 @@ export function useElementSettingsForm(options: UseElementSettingsFormOptions) {
|
|||||||
zIndex: state.zIndex,
|
zIndex: state.zIndex,
|
||||||
backgroundColor: state.backgroundColor,
|
backgroundColor: state.backgroundColor,
|
||||||
color: state.color,
|
color: state.color,
|
||||||
fontFamily: state.fontFamily,
|
|
||||||
};
|
};
|
||||||
}, [state]);
|
}, [state]);
|
||||||
|
|
||||||
@ -581,11 +572,9 @@ export function useElementSettingsForm(options: UseElementSettingsFormOptions) {
|
|||||||
// Additional CSS properties
|
// Additional CSS properties
|
||||||
const backgroundColorValue = toOptionalTrimmed(state.backgroundColor);
|
const backgroundColorValue = toOptionalTrimmed(state.backgroundColor);
|
||||||
const colorValue = toOptionalTrimmed(state.color);
|
const colorValue = toOptionalTrimmed(state.color);
|
||||||
const fontFamilyValue = toOptionalTrimmed(state.fontFamily);
|
|
||||||
|
|
||||||
if (backgroundColorValue) settings.backgroundColor = backgroundColorValue;
|
if (backgroundColorValue) settings.backgroundColor = backgroundColorValue;
|
||||||
if (colorValue) settings.color = colorValue;
|
if (colorValue) settings.color = colorValue;
|
||||||
if (fontFamilyValue) settings.fontFamily = fontFamilyValue;
|
|
||||||
|
|
||||||
// Effect properties
|
// Effect properties
|
||||||
const appearAnimationValue = toOptionalTrimmed(state.appearAnimation);
|
const appearAnimationValue = toOptionalTrimmed(state.appearAnimation);
|
||||||
@ -677,8 +666,6 @@ export function useElementSettingsForm(options: UseElementSettingsFormOptions) {
|
|||||||
state.descriptionTitleColor.trim() || '#000000';
|
state.descriptionTitleColor.trim() || '#000000';
|
||||||
settings.descriptionTextColor =
|
settings.descriptionTextColor =
|
||||||
state.descriptionTextColor.trim() || '#4B5563';
|
state.descriptionTextColor.trim() || '#4B5563';
|
||||||
settings.descriptionBackgroundColor =
|
|
||||||
state.descriptionBackgroundColor.trim() || 'transparent';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gallery type settings
|
// Gallery type settings
|
||||||
|
|||||||
@ -63,11 +63,10 @@ const DescriptionElement: React.FC<DescriptionElementProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Without icon: render styled text description
|
// Without icon: render styled text description
|
||||||
const bgColor = element.descriptionBackgroundColor || 'transparent';
|
// Background color is controlled via CSS Styles tab (backgroundColor property)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className} style={style}>
|
<div className={className} style={style}>
|
||||||
<div className='p-4 rounded' style={{ backgroundColor: bgColor }}>
|
<div className='p-4'>
|
||||||
<p
|
<p
|
||||||
className='font-bold'
|
className='font-bold'
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@ -61,8 +61,8 @@ export function useElementWrapperStyle({
|
|||||||
const hasTransparentBackground =
|
const hasTransparentBackground =
|
||||||
(isDescriptionElementType(element.type) &&
|
(isDescriptionElementType(element.type) &&
|
||||||
!element.iconUrl &&
|
!element.iconUrl &&
|
||||||
(!element.descriptionBackgroundColor ||
|
(!element.backgroundColor ||
|
||||||
element.descriptionBackgroundColor === 'transparent')) ||
|
element.backgroundColor === 'transparent')) ||
|
||||||
(isNavigationElementType(element.type) && Boolean(element.iconUrl)) ||
|
(isNavigationElementType(element.type) && Boolean(element.iconUrl)) ||
|
||||||
isTooltipElementType(element.type) ||
|
isTooltipElementType(element.type) ||
|
||||||
isGalleryElementType(element.type) ||
|
isGalleryElementType(element.type) ||
|
||||||
|
|||||||
@ -124,7 +124,6 @@ export const TYPE_SPECIFIC_DEFAULTS: Partial<
|
|||||||
descriptionTextFontFamily: 'inherit',
|
descriptionTextFontFamily: 'inherit',
|
||||||
descriptionTitleColor: '#ffffff',
|
descriptionTitleColor: '#ffffff',
|
||||||
descriptionTextColor: '#ffffff',
|
descriptionTextColor: '#ffffff',
|
||||||
descriptionBackgroundColor: 'transparent',
|
|
||||||
},
|
},
|
||||||
gallery: {
|
gallery: {
|
||||||
galleryCards: [],
|
galleryCards: [],
|
||||||
@ -514,11 +513,6 @@ export const buildElementSettings = (
|
|||||||
'descriptionTextColor',
|
'descriptionTextColor',
|
||||||
element.descriptionTextColor,
|
element.descriptionTextColor,
|
||||||
);
|
);
|
||||||
addIfNotEmpty(
|
|
||||||
settings,
|
|
||||||
'descriptionBackgroundColor',
|
|
||||||
element.descriptionBackgroundColor,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gallery type settings
|
// Gallery type settings
|
||||||
|
|||||||
@ -36,8 +36,6 @@ export interface ElementStyleProperties {
|
|||||||
zIndex?: string;
|
zIndex?: string;
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
fontFamily?: string;
|
|
||||||
fontStretch?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,8 +66,6 @@ export const ELEMENT_STYLE_PROPS = [
|
|||||||
'zIndex',
|
'zIndex',
|
||||||
'backgroundColor',
|
'backgroundColor',
|
||||||
'color',
|
'color',
|
||||||
'fontFamily',
|
|
||||||
'fontStretch',
|
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -341,9 +341,6 @@ const ElementTypeDefaultDetailsPage = () => {
|
|||||||
}
|
}
|
||||||
descriptionTitleColor={form.state.descriptionTitleColor}
|
descriptionTitleColor={form.state.descriptionTitleColor}
|
||||||
descriptionTextColor={form.state.descriptionTextColor}
|
descriptionTextColor={form.state.descriptionTextColor}
|
||||||
descriptionBackgroundColor={
|
|
||||||
form.state.descriptionBackgroundColor
|
|
||||||
}
|
|
||||||
onChange={handleTypeChange}
|
onChange={handleTypeChange}
|
||||||
context='global'
|
context='global'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -526,9 +526,6 @@ const ProjectElementDefaultDetailsPage = () => {
|
|||||||
}
|
}
|
||||||
descriptionTitleColor={form.state.descriptionTitleColor}
|
descriptionTitleColor={form.state.descriptionTitleColor}
|
||||||
descriptionTextColor={form.state.descriptionTextColor}
|
descriptionTextColor={form.state.descriptionTextColor}
|
||||||
descriptionBackgroundColor={
|
|
||||||
form.state.descriptionBackgroundColor
|
|
||||||
}
|
|
||||||
onChange={handleTypeChange}
|
onChange={handleTypeChange}
|
||||||
context='project'
|
context='project'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -115,7 +115,6 @@ export interface CanvasElement extends BaseCanvasElement {
|
|||||||
descriptionTextFontFamily?: string;
|
descriptionTextFontFamily?: string;
|
||||||
descriptionTitleColor?: string;
|
descriptionTitleColor?: string;
|
||||||
descriptionTextColor?: string;
|
descriptionTextColor?: string;
|
||||||
descriptionBackgroundColor?: string;
|
|
||||||
navLabel?: string;
|
navLabel?: string;
|
||||||
navLabelFontFamily?: string;
|
navLabelFontFamily?: string;
|
||||||
navType?: NavigationButtonKind;
|
navType?: NavigationButtonKind;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user