@wpnuxt/blocks 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@wpnuxt/blocks",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "configKey": "wpNuxtBlocks",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.8.1",
6
+ "@nuxt/module-builder": "0.8.3",
7
7
  "unbuild": "2.0.0"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { defineNuxtModule, createResolver, installModule, addComponentsDir, addC
3
3
  import { genDynamicImport } from 'knitwork';
4
4
 
5
5
  const name = "@wpnuxt/blocks";
6
- const version = "0.0.6";
6
+ const version = "0.0.7";
7
7
 
8
8
  const module = defineNuxtModule({
9
9
  meta: {
@@ -27,11 +27,9 @@ const componentToRender = await findComponentToRender()
27
27
  </script>
28
28
 
29
29
  <template>
30
- <div>
31
- <component
32
- :is="componentToRender"
33
- v-if="componentToRender"
34
- :block="block"
35
- />
36
- </div>
30
+ <component
31
+ :is="componentToRender"
32
+ v-if="componentToRender"
33
+ :block="block"
34
+ />
37
35
  </template>
@@ -3,7 +3,7 @@ import BlockComponent from './BlockComponent.vue'
3
3
  import type { EditorBlock } from '#wpnuxt/blocks'
4
4
 
5
5
  defineProps<{
6
- blocks: EditorBlock[]
6
+ blocks: EditorBlock[] | undefined
7
7
  }>()
8
8
  </script>
9
9
 
@@ -1,18 +1,29 @@
1
1
  <script setup lang="ts">
2
+ import { convertFontSize, getCssClasses } from '../../util'
2
3
  import type { CoreButton } from '#wpnuxt/blocks'
4
+ import { ref } from '#imports'
3
5
 
4
- defineProps<{
6
+ const props = defineProps<{
5
7
  block: CoreButton
6
8
  }>()
9
+ const variant = ref('solid')
10
+ /* if (props.block.attributes?.cssClassName?.includes('is-style-outline')) {
11
+ variant.value = 'outline'
12
+ } */
13
+ if (props.block.attributes?.metadata) {
14
+ variant.value = props.block.attributes?.metadata?.replaceAll('"', '')
15
+ }
7
16
  </script>
8
17
 
9
18
  <template>
10
19
  <UButton
11
20
  :to="block.attributes.url"
12
21
  :target="block.attributes.linkTarget"
13
- :class="block.attributes.cssClassName"
14
22
  :rel="block.attributes.rel"
15
23
  :style="block.attributes.style"
24
+ :variant
25
+ :class="getCssClasses(props.block)"
26
+ :size="convertFontSize(props.block.attributes?.fontSize, '', 'md')"
16
27
  >
17
28
  <span v-sanitize="block.attributes.text" />
18
29
  </UButton>
@@ -7,17 +7,19 @@ defineProps<{
7
7
  </script>
8
8
 
9
9
  <template>
10
- <div
11
- v-for="innerBlock, index in block.innerBlocks"
12
- :key="index"
13
- >
14
- <CoreButton
15
- v-if="innerBlock.name === 'core/button'"
16
- :block="innerBlock"
17
- />
18
- <EditorBlock
19
- v-else
20
- :block="innerBlock"
21
- />
10
+ <div>
11
+ <template
12
+ v-for="innerBlock, index in block.innerBlocks"
13
+ :key="index"
14
+ >
15
+ <CoreButton
16
+ v-if="innerBlock.name === 'core/button'"
17
+ :block="innerBlock"
18
+ />
19
+ <EditorBlock
20
+ v-else
21
+ :block="innerBlock"
22
+ />
23
+ </template>
22
24
  </div>
23
25
  </template>
@@ -1,28 +1,54 @@
1
1
  <script setup lang="ts">
2
+ import { getCssClasses } from '../../util'
2
3
  import type { CoreHeading } from '#wpnuxt/blocks'
3
4
 
4
- defineProps<{
5
+ const props = defineProps<{
5
6
  block: CoreHeading
6
7
  }>()
8
+ const cssClass = getCssClasses(props.block)
7
9
  </script>
8
10
 
9
11
  <template>
10
12
  <template v-if="block.attributes.level === 1">
11
- <h1 v-sanitize="block.attributes.content" />
13
+ <h1
14
+ :id="block?.attributes?.anchor"
15
+ v-sanitize="block.attributes.content"
16
+ :class="cssClass"
17
+ />
12
18
  </template>
13
- <template v-if="block.attributes.level === 2">
14
- <h2 v-sanitize="block.attributes.content" />
19
+ <template v-else-if="block.attributes.level === 2">
20
+ <h2
21
+ :id="block?.attributes?.anchor"
22
+ v-sanitize="block.attributes.content"
23
+ :class="cssClass"
24
+ />
15
25
  </template>
16
- <template v-if="block.attributes.level === 3">
17
- <h3 v-sanitize="block.attributes.content" />
26
+ <template v-else-if="block.attributes.level === 3">
27
+ <h3
28
+ :id="block?.attributes?.anchor"
29
+ v-sanitize="block.attributes.content"
30
+ :class="cssClass"
31
+ />
18
32
  </template>
19
- <template v-if="block.attributes.level === 4">
20
- <h4 v-sanitize="block.attributes.content" />
33
+ <template v-else-if="block.attributes.level === 4">
34
+ <h4
35
+ :id="block?.attributes?.anchor"
36
+ v-sanitize="block.attributes.content"
37
+ :class="cssClass"
38
+ />
21
39
  </template>
22
- <template v-if="block.attributes.level === 5">
23
- <h5 v-sanitize="block.attributes.content" />
40
+ <template v-else-if="block.attributes.level === 5">
41
+ <h5
42
+ :id="block?.attributes?.anchor"
43
+ v-sanitize="block.attributes.content"
44
+ :class="cssClass"
45
+ />
24
46
  </template>
25
- <template v-if="block.attributes.level === 6">
26
- <h6 v-sanitize="block.attributes.content" />
47
+ <template v-else-if="block.attributes.level === 6">
48
+ <h6
49
+ :id="block?.attributes?.anchor"
50
+ v-sanitize="block.attributes.content"
51
+ :class="cssClass"
52
+ />
27
53
  </template>
28
54
  </template>
@@ -1,13 +1,18 @@
1
1
  <script setup lang="ts">
2
+ import { getCssClasses } from '../../util'
2
3
  import type { CoreParagraph } from '#wpnuxt/blocks'
3
4
 
4
- defineProps<{
5
+ const props = defineProps<{
5
6
  block: CoreParagraph
6
7
  }>()
8
+ const cssClass = getCssClasses(props.block)
7
9
  </script>
8
10
 
9
11
  <template>
10
- <div>
11
- <p v-sanitize="block?.attributes?.content" />
12
- </div>
12
+ <p
13
+ :id="block?.attributes?.anchor"
14
+ v-sanitize="block?.attributes?.content"
15
+ :class="cssClass"
16
+ :style="block?.attributes?.style"
17
+ />
13
18
  </template>
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ import { getCssClasses } from '../../util'
3
+ import type { CoreSpacer } from '#wpnuxt/blocks'
4
+
5
+ const props = defineProps<{
6
+ block: CoreSpacer
7
+ }>()
8
+ const cssClass = getCssClasses(props.block)
9
+ </script>
10
+
11
+ <template>
12
+ <div
13
+ :class="cssClass"
14
+ :style="{
15
+ height: block.attributes?.spacerHeight,
16
+ width: block.attributes?.spacerWidth
17
+ }"
18
+ />
19
+ </template>
@@ -0,0 +1,11 @@
1
+ fragment CoreSpacer on CoreSpacer {
2
+ attributes {
3
+ anchor
4
+ className
5
+ spacerHeight: height
6
+ spacerWidth: width
7
+ lock
8
+ metadata
9
+ style
10
+ }
11
+ }
@@ -4,6 +4,7 @@
4
4
  #import '~/.queries/fragments/CoreImage.fragment.gql';
5
5
  #import '~/.queries/fragments/CoreParagraph.fragment.gql';
6
6
  #import '~/.queries/fragments/CoreQuote.fragment.gql';
7
+ #import '~/.queries/fragments/CoreSpacer.fragment.gql';
7
8
 
8
9
  fragment EditorBlock on EditorBlock {
9
10
  apiVersion
@@ -20,4 +21,5 @@ fragment EditorBlock on EditorBlock {
20
21
  ...CoreImage
21
22
  ...CoreParagraph
22
23
  ...CoreQuote
24
+ ...CoreSpacer
23
25
  }
@@ -0,0 +1 @@
1
+ export declare const getColor: (textColor?: string) => string;
@@ -0,0 +1,4 @@
1
+ export const getColor = function getColor2(textColor) {
2
+ if (textColor == "accent-3") return "text-primary-500";
3
+ return "";
4
+ };
@@ -0,0 +1 @@
1
+ export declare const convertFontSize: (fontSize: string, prefix?: string, defaultSize?: string) => string;
@@ -0,0 +1,18 @@
1
+ export const convertFontSize = function convertFontSize2(fontSize, prefix, defaultSize) {
2
+ if (!prefix) prefix = "";
3
+ if (fontSize && fontSize !== "" && fontSize !== "null") {
4
+ switch (fontSize) {
5
+ case "small":
6
+ return prefix + "sm";
7
+ case "medium":
8
+ return prefix + "md";
9
+ case "large":
10
+ return prefix + "lg";
11
+ case "x-large":
12
+ return prefix + "xl";
13
+ case "xx-large":
14
+ return prefix + "2xl";
15
+ }
16
+ }
17
+ return defaultSize ? prefix + defaultSize : "";
18
+ };
@@ -0,0 +1,4 @@
1
+ import { convertFontSize } from './attributeFontSize.js';
2
+ import { getColor } from './attributeColor.js';
3
+ declare const getCssClasses: (block: any) => string;
4
+ export { getCssClasses, convertFontSize, getColor };
@@ -0,0 +1,9 @@
1
+ import { convertFontSize } from "./attributeFontSize.js";
2
+ import { getColor } from "./attributeColor.js";
3
+ const getCssClasses = function getCssClasses2(block) {
4
+ const text = convertFontSize(block.attributes?.fontSize, "text-");
5
+ const color = getColor(block.attributes?.textColor);
6
+ const passedOn = block?.attributes?.className != null ? block?.attributes?.className + " " : " ";
7
+ return passedOn + text + " " + color;
8
+ };
9
+ export { getCssClasses, convertFontSize, getColor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpnuxt/blocks",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "WPNuxt Blocks",
5
5
  "repository": "wpnuxt/wpnuxt-blocks",
6
6
  "license": "MIT",
@@ -31,21 +31,25 @@
31
31
  "lint:fix": "eslint . --fix",
32
32
  "test": "vitest run",
33
33
  "test:watch": "vitest watch",
34
- "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
34
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
35
+ "wp-env": "wp-env",
36
+ "wp-env:create": "wp-env start --update && ./wordpress/wp-env-cli.sh",
37
+ "start": "pnpm run wp-env:create && pnpm run dev"
35
38
  },
36
39
  "dependencies": {
37
40
  "@nuxt/image": "^1.7.0",
38
41
  "@nuxt/kit": "^3.12.4",
39
42
  "@nuxt/ui": "^2.18.4",
40
- "@wpnuxt/core": "^1.0.0-edge.6"
43
+ "@wpnuxt/core": "^1.0.0-edge.8"
41
44
  },
42
45
  "devDependencies": {
43
46
  "@nuxt/devtools": "^1.3.9",
44
47
  "@nuxt/eslint-config": "^0.5.0",
45
- "@nuxt/module-builder": "^0.8.1",
48
+ "@nuxt/module-builder": "^0.8.3",
46
49
  "@nuxt/schema": "^3.12.4",
47
- "@nuxt/test-utils": "^3.13.1",
48
- "@types/node": "^22.2.0",
50
+ "@nuxt/test-utils": "^3.14.1",
51
+ "@types/node": "^22.4.1",
52
+ "@wordpress/env": "^10.5.0",
49
53
  "changelogen": "^0.5.5",
50
54
  "eslint": "^9.9.0",
51
55
  "nuxt": "^3.12.4",
@@ -57,5 +61,6 @@
57
61
  "peerDependencies": {
58
62
  "knitwork": "^1.1.0",
59
63
  "pathe": "^1.1.2"
60
- }
64
+ },
65
+ "packageManager": "pnpm@9.7.0"
61
66
  }