✨ ags(separator): make the separator background customizable
This commit is contained in:
+26
-16
@@ -7,31 +7,41 @@ export interface SeparatorProps {
|
|||||||
cssColor?: string;
|
cssColor?: string;
|
||||||
orientation?: Gtk.Orientation;
|
orientation?: Gtk.Orientation;
|
||||||
size?: number;
|
size?: number;
|
||||||
visible?: boolean | Binding<boolean | undefined>;
|
visible?: boolean | Binding<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Separator(props: SeparatorProps) {
|
export function Separator(props: SeparatorProps) {
|
||||||
const alpha: number = props.alpha ?
|
props.alpha = props.alpha ?
|
||||||
(props.alpha > 1) ?
|
(props.alpha > 1 ?
|
||||||
props.alpha / 100
|
props.alpha / 100
|
||||||
: props.alpha
|
: props.alpha)
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
return new Widget.Box({
|
return new Widget.Box({
|
||||||
className: `separator separator-${ props.orientation == Gtk.Orientation.VERTICAL ?
|
name: "separator",
|
||||||
"vertical" : "horizontal" } ${ props.class && props.class }`,
|
className: `separator ${ props.orientation === Gtk.Orientation.VERTICAL ?
|
||||||
|
"vertical" : "horizontal" }`,
|
||||||
visible: props.visible,
|
visible: props.visible,
|
||||||
css: `.separator {
|
css: `.vertical {
|
||||||
background: ${ props.cssColor || "lightgray" };
|
padding: 7px 7px;
|
||||||
opacity: ${alpha};
|
|
||||||
}
|
}
|
||||||
.separator-horizontal {
|
.horizontal {
|
||||||
min-width: ${ props.size || 1 }px;
|
padding: 4px 4px;
|
||||||
margin: 4px 4px;
|
|
||||||
}
|
|
||||||
.separator-vertical {
|
|
||||||
min-height: ${ props.size || 1 }px;
|
|
||||||
margin: 7px 7px;
|
|
||||||
}`,
|
}`,
|
||||||
|
child: new Widget.Box({
|
||||||
|
className: `${ props.orientation === Gtk.Orientation.VERTICAL ?
|
||||||
|
"vertical" : "horizontal" } ${ props.class ? props.class : "" }`,
|
||||||
|
css: `* {
|
||||||
|
background: ${ props.cssColor || "lightgray" };
|
||||||
|
opacity: ${props.alpha};
|
||||||
|
}
|
||||||
|
.horizontal {
|
||||||
|
min-width: ${ props.size || 1 }px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vertical {
|
||||||
|
min-height: ${ props.size || 1 }px;
|
||||||
|
}`
|
||||||
|
} as Widget.BoxProps)
|
||||||
} as Widget.BoxProps);
|
} as Widget.BoxProps);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user