Skip to content

Commit

Permalink
cleanup editor layout (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
idaho committed Jan 4, 2024
1 parent 4a4b41c commit 16a5806
Show file tree
Hide file tree
Showing 16 changed files with 659 additions and 397 deletions.
3 changes: 2 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const plugins = [
files: IGNORED_FILES.map(file => require.resolve(file))
}),
typescript({
declaration: false
declaration: false,
exclude: [ '**/*.test.ts' ]
}),
nodeResolve(),
json(),
Expand Down
89 changes: 89 additions & 0 deletions src/cards/trash-card/formSchemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import type { HaFormSchema } from '../../utils/form/ha-form';
import type setupCustomlocalize from '../../localize';

// eslint-disable-next-line @typescript-eslint/naming-convention
const SCHEMA_PATTERN_OTHERS: HaFormSchema[] = [
{
label: 'icon',
name: 'icon',
selector: { icon: {}},
// eslint-disable-next-line @typescript-eslint/naming-convention
context: { icon_entity: 'entity' }
},
// eslint-disable-next-line @typescript-eslint/naming-convention
{ label: 'color', name: 'color', selector: { ui_color: {}}}

];

// eslint-disable-next-line @typescript-eslint/naming-convention
const SCHEMA_PATTERN: HaFormSchema[] = [
{ label: 'label', name: 'label', selector: { text: {}}},
...SCHEMA_PATTERN_OTHERS,
{ label: 'pattern', name: 'pattern', selector: { text: {}}}
];

const getSchema = (customLocalize: ReturnType<typeof setupCustomlocalize>) => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const settings: HaFormSchema[] = [

// eslint-disable-next-line @typescript-eslint/naming-convention
{ name: 'filter_events', selector: { boolean: {}}},
{ name: 'drop_todayevents_from',
default: {
hours: 11,
minutes: 0,
seconds: 0
},
selector: {
time: {
}
}},
{ name: 'next_days',
selector: { number: {
min: 1,
max: 365,
step: 1,
mode: 'box'
}}}

];

// eslint-disable-next-line @typescript-eslint/naming-convention
const appearance: HaFormSchema[] = [

// eslint-disable-next-line @typescript-eslint/naming-convention
{ name: 'layout', selector: { mush_layout: {}}},
{ name: 'fill_container', selector: { boolean: {}}},
{ name: 'full_size', selector: { boolean: {}}},
{ name: 'use_summary', selector: { boolean: {}}},
// eslint-disable-next-line @typescript-eslint/naming-convention
{ name: 'day_style', selector: { trashcard_datestyle: {}}}
];

// eslint-disable-next-line @typescript-eslint/naming-convention
const schema: HaFormSchema[] = [
{ name: 'entity', selector: { entity: { domain: 'calendar' }}},
{
type: 'expandable',
name: '',
title: customLocalize('editor.form.tabs.settings'),
icon: 'mdi:cog',
schema: settings
},
{
type: 'expandable',
name: '',
title: customLocalize('editor.form.tabs.appearance'),
icon: 'mdi:palette',
schema: appearance
}
];

return schema;
};

export {
getSchema,
SCHEMA_PATTERN,
SCHEMA_PATTERN_OTHERS
};
Loading

0 comments on commit 16a5806

Please sign in to comment.