-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(demo): improve cms-text-element (#283)
* fix(demo): improve cms-text-element * chore: add changesets
- Loading branch information
1 parent
aed2413
commit 7bff62f
Showing
8 changed files
with
165 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopware-pwa/composables-next": patch | ||
--- | ||
|
||
Fixed initial listing suring search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopware-pwa/cms-base": minor | ||
--- | ||
|
||
CmsElementText has now proper support for colors and align, when set in admin panel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"vue-demo-store": minor | ||
--- | ||
|
||
Moved UnoCSS config into separate file, enabled preflight for styles reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 38 additions & 7 deletions
45
packages/cms-base/helpers/html-to-vue/getOptionsFromNode.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,46 @@ | ||
export type NodeObject = { | ||
type: string; | ||
name: string; | ||
attrs?: Options; | ||
children: NodeObject[]; | ||
voidElement: boolean; | ||
content: string; | ||
}; | ||
|
||
type Options = { | ||
style: String; | ||
class: String; | ||
attrs: Object; | ||
align?: string; | ||
attrs?: Record<string, string>; | ||
class?: string; | ||
color?: string; | ||
style?: string; | ||
}; | ||
|
||
export function getOptionsFromNode(node: any): Options { | ||
const { style, class: classArs, ...rest } = node.attrs; | ||
let style = null; | ||
let classNames = null; | ||
let align = null; | ||
|
||
if (node.attrs.style && node.attrs.style !== "") { | ||
style = node.attrs.style; | ||
delete node.attrs.style; // we delete the nodes otherwise it would be added to rest again | ||
} | ||
|
||
if (node.attrs.class && node.attrs.class !== "") { | ||
classNames = node.attrs.class; | ||
delete node.attrs.class; | ||
} | ||
|
||
if (node.attrs.align && node.attrs.align !== "") { | ||
align = node.attrs.align; | ||
delete node.attrs.align; | ||
} | ||
|
||
const attrs = Object.keys(node.attrs).length === 0 ? null : { ...node.attrs }; | ||
|
||
return { | ||
style, | ||
attrs: rest, | ||
class: classArs, | ||
align: align, | ||
attrs: attrs, | ||
class: classNames, | ||
style: style, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
defineConfig, | ||
presetAttributify, | ||
presetIcons, | ||
presetTypography, | ||
presetUno, | ||
} from "unocss"; | ||
import transformerDirectives from "@unocss/transformer-directives"; | ||
|
||
export default defineConfig({ | ||
theme: { | ||
extend: { | ||
width: "width", | ||
height: "height", | ||
}, | ||
colors: { | ||
brand: { | ||
primary: "#189eff", | ||
light: "#5ebbff", | ||
dark: "#0081df", | ||
}, | ||
}, | ||
}, | ||
presets: [ | ||
presetUno(), | ||
presetIcons({ | ||
collections: { | ||
carbon: () => | ||
import("@iconify-json/carbon/icons.json").then((i) => i.default), | ||
}, | ||
}), | ||
presetAttributify(), | ||
presetTypography(), | ||
], | ||
transformers: [transformerDirectives()], | ||
preflights: [ | ||
// preflights can be used to set some base styles | ||
{ | ||
getCSS: () => ` | ||
h1 { | ||
line-height: 2.5rem; | ||
font-size: 2.25rem; | ||
} | ||
h2 { | ||
line-height: 2rem; | ||
font-size: 1.75rem; | ||
} | ||
h3 { | ||
line-height: 1.5rem; | ||
font-size: 1.25rem; | ||
} | ||
ol, | ||
ul, | ||
dl { | ||
list-style-type: disc; | ||
padding-left: 40px; | ||
margin-top: 0; | ||
margin-bottom: 1rem; | ||
} | ||
ol { | ||
list-style-type: decimal; | ||
} | ||
`, | ||
}, | ||
], | ||
}); |