1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { useEditor } from "@/modules/editor";
- import { css } from "@linaria/core";
- import { watch } from "vue";
- import { string } from "vue-types";
- import { useCompData, useCreateChild } from ".";
- import { Text } from "../../../basicUI";
- import { createUIComp } from "../../../defines/createUIComp";
- export const Component = createUIComp({
- props: {
- compId: string().isRequired,
- },
- setup(props) {
- const { helper } = useEditor();
- const { value, children } = useCompData(props.compId);
- const createList = useCreateChild("list");
- watch(
- () => [value.columns],
- () => {
- const { columns } = value;
- const { list } = children;
- const offset = columns - list.length;
- if (offset > 0) {
- children.list.push(...createList(offset));
- } else {
- list.splice(columns, offset * -1);
- }
- }
- );
- return () => (
- <div class={rootStyles}>
- {children.list.map((d) => (
- <div
- class="flex items-center text-primary px-0.1rem"
- style={{
- margin: helper.designToNaturalSize(value.gap),
- }}
- >
- <Text.Component
- compId={d.label}
- class={
- value.showBackground
- ? "text relative z-0 py-0.08rem px-0.1rem text-white"
- : "text-secondary"
- }
- style={{
- width: helper.designToNaturalSize(value.width),
- }}
- />
- <Text.Component compId={d.content} class="flex-1 ml-0.3rem" />
- </div>
- ))}
- </div>
- );
- },
- });
- const rootStyles = css`
- .text {
- &::before {
- content: "";
- position: absolute;
- top: 0;
- left: 4%;
- width: 92%;
- height: 100%;
- background-color: #333;
- transform: skewX(345deg);
- z-index: -1;
- }
- }
- `;
|