Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow <SanityContent> to use :deep() selectors for custom styling #692

Open
davidstackio opened this issue Feb 24, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@davidstackio
Copy link

davidstackio commented Feb 24, 2023

I've followed the instructions about wrapping a portable text component to add my custom serializers. However, one thing I also do is add custom formatting here.

For example in the <style> tag:

<script setup lang="ts">
import type { PortableTextBlock } from "@portabletext/types";

defineProps({
  blocks: {
    type: Array<PortableTextBlock>,
    required: true,
  },
});
</script>

<template>
  <SanityContent :blocks="blocks" />
</template>

<style scoped>
:deep(a) {
  text-decoration: none;
}
:deep(a:hover) {
  text-decoration: underline;
}

:deep(h2),
:deep(h3) {
  margin-top: 48px;
  margin-bottom: 12px;
}

:deep(p) {
  margin-bottom: 16px;
}

:deep(ul),
:deep(ol) {
  margin-bottom: 12px;
  padding-left: 24px;
}
</style>

However, this does not work since Vue does not seem to be able to apply any of the :deep() selectors to a purely functional component, which <SanityContent> is.

Describe the solution you'd like to see

Either update the docs to suggest wrapping it in a div, or make <SanityContent> a rendered component so :deep() can be used.

Describe alternatives you've considered

My current workaround is wrapping <SanityContent> in a div.

<template>
  <div>
    <SanityContent :blocks="content" />
  </div>
</template>

This correctly applies all my styles.

@davidstackio davidstackio added the enhancement New feature or request label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant