mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-17 17:40:31 +08:00
change style trait params to array
This commit is contained in:
parent
736ef98bd0
commit
9ae0623a7a
@ -82,9 +82,13 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
{
|
||||
type: 'core/v1/style',
|
||||
properties: {
|
||||
styleSlot: 'content',
|
||||
style: "{{!usersTable.selectedItem ? 'display: none' : ''}}",
|
||||
},
|
||||
styles: [
|
||||
{
|
||||
styleSlot: 'content',
|
||||
style: "{{!usersTable.selectedItem ? 'display: none' : ''}}",
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -110,7 +114,7 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
},
|
||||
{
|
||||
type: 'core/v1/style',
|
||||
properties: { styleSlot: 'content', style: 'padding: 0; border: none' },
|
||||
properties: { styles: [{styleSlot: 'content', style: 'padding: 0; border: none' }]},
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -174,7 +178,7 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
},
|
||||
{
|
||||
type: 'core/v1/style',
|
||||
properties: { styleSlot: 'content', style: 'padding: 0; border: none' },
|
||||
properties: { styles: [{styleSlot: 'content', style: 'padding: 0; border: none' }]},
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -241,7 +245,6 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
type: 'core/v1/slot',
|
||||
properties: { container: { id: 'hstack4', slot: 'content' } },
|
||||
},
|
||||
{ type: 'core/v1/style', properties: { string: { kind: {}, type: {} } } },
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -255,7 +258,7 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
},
|
||||
{
|
||||
type: 'core/v1/style',
|
||||
properties: { styleSlot: 'content', style: 'padding: 0; border: none' },
|
||||
properties: { styles: [{styleSlot: 'content', style: 'padding: 0; border: none' }]},
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -281,7 +284,7 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
},
|
||||
{
|
||||
type: 'core/v1/style',
|
||||
properties: { styleSlot: 'content', style: 'padding: 0; border: none' },
|
||||
properties: { styles: [{styleSlot: 'content', style: 'padding: 0; border: none' }]},
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -329,7 +332,7 @@ export const ApplicationFixture: Record<string, Application> = {
|
||||
},
|
||||
{
|
||||
type: 'core/v1/style',
|
||||
properties: { styleSlot: 'content', style: 'padding: 0; border: none' },
|
||||
properties: { styles: [{styleSlot: 'content', style: 'padding: 0; border: none' }]},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -2,22 +2,25 @@ import { createTrait } from '@sunmao-ui/core';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import { TraitImplementation } from '../../types/RuntimeSchema';
|
||||
|
||||
const StyleTrait: TraitImplementation<Static<typeof PropsSchema>> = ({
|
||||
styleSlot,
|
||||
style,
|
||||
}) => {
|
||||
const StyleTrait: TraitImplementation<Static<typeof PropsSchema>> = ({ styles }) => {
|
||||
const customStyle: Record<string, string> = {};
|
||||
styles.forEach(style => {
|
||||
customStyle[style.styleSlot] = style.style;
|
||||
});
|
||||
return {
|
||||
props: {
|
||||
customStyle: {
|
||||
[styleSlot]: style,
|
||||
},
|
||||
customStyle,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const PropsSchema = Type.Object({
|
||||
styleSlot: Type.String(),
|
||||
style: Type.String(),
|
||||
styles: Type.Array(
|
||||
Type.Object({
|
||||
styleSlot: Type.String(),
|
||||
style: Type.String(),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
||||
export default {
|
||||
|
Loading…
Reference in New Issue
Block a user