Skip to content

28 toggle with heading bug #32

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

Merged
merged 2 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions src/blocks/header.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue"
import { useNotionBlock, defineNotionProps } from "@/lib/blockable";
import NotionHeaderRenderer from "@/blocks/helpers/header-renderer.vue";
import NotionRenderer from "@/components/notion-renderer.vue";

const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { type, title, pass, block } = useNotionBlock(props)
const { type, title, pass, block, format } = useNotionBlock(props);
</script>

<script lang="ts">
export default {
name: "NotionHeader",
}
};
</script>

<template>
<h1 class="notion-h1" :id="block.value.id" v-if="type === 'header'">
<NotionTextRenderer :text="title" v-bind="pass" />
</h1>
<h2 class="notion-h2" :id="block.value.id" v-else-if="type === 'sub_header'">
<NotionTextRenderer :text="title" v-bind="pass" />
</h2>
<h3 class="notion-h3" :id="block.value.id" v-else-if="type === 'sub_sub_header'">
<NotionTextRenderer :text="title" v-bind="pass" />
</h3>
<details v-if="format?.toggleable" class="notion-toggle">
<summary><NotionHeaderRenderer class="notion-h" v-bind="pass"></NotionHeaderRenderer></summary>
<div>
<NotionRenderer
v-for="(contentId, contentIndex) in block.value.content"
v-bind="pass"
:key="contentId"
:level="pass.level + 1"
:content-id="contentId"
:content-index="contentIndex"
></NotionRenderer>
</div>
</details>
<NotionHeaderRenderer v-else v-bind="pass"></NotionHeaderRenderer>
</template>
26 changes: 26 additions & 0 deletions src/blocks/helpers/header-renderer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable";
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue";

const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { type, title, pass, block } = useNotionBlock(props);
</script>

<script lang="ts">
export default {
name: "NotionHeaderRenderer",
};
</script>

<template>
<h1 class="notion-h1" :id="block.value.id" v-if="type === 'header'">
<NotionTextRenderer :text="title" v-bind="pass" />
</h1>
<h2 class="notion-h2" :id="block.value.id" v-else-if="type === 'sub_header'">
<NotionTextRenderer :text="title" v-bind="pass" />
</h2>
<h3 class="notion-h3" :id="block.value.id" v-else-if="type === 'sub_sub_header'">
<NotionTextRenderer :text="title" v-bind="pass" />
</h3>
</template>
43 changes: 18 additions & 25 deletions src/blocks/helpers/page-icon.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import { getTextContent } from "@/lib/utils"
import DefaultPageIcon from "./default-page-icon.vue"
import { useNotionBlock, defineNotionProps } from "@/lib/blockable";
import { getTextContent } from "@/lib/utils";
import DefaultPageIcon from "./default-page-icon.vue";

const props = defineProps({ big: Boolean, ...defineNotionProps })
const props = defineProps({ big: Boolean, ...defineNotionProps });
//@ts-ignore
const { icon, format, block, title } = useNotionBlock(props)
const { icon, format, block, title } = useNotionBlock(props);
</script>

<script lang="ts">
export default {
name: "NotionPageIcon",
}
};
</script>

<template>
<img
v-if="icon?.includes('http')"
:class="[format.page_cover && 'notion-page-icon-offset', big ? 'notion-page-icon-cover' : 'notion-page-icon']"
:src="props.mapImageUrl(icon, block)"
:alt="title ? getTextContent(title) : 'Icon'"
/>
<span
v-else-if="icon"
role="img"
:aria-label="icon"
:class="[
'notion-emoji',
format.page_cover && 'notion-page-icon-offset',
big ? 'notion-page-icon-cover' : 'notion-page-icon',
]"
>
{{ icon }}
</span>
<DefaultPageIcon class="notion-page-icon" v-else-if="!big"></DefaultPageIcon>
<div :class="[format.page_cover && 'notion-page-icon-offset', big ? 'notion-page-icon-cover' : 'notion-page-icon']">
<img
v-if="icon?.includes('http')"
:src="props.mapImageUrl(icon, block)"
:alt="title ? getTextContent(title) : 'Icon'"
class="notion-page-icon"
/>
<span v-else-if="icon" role="img" :aria-label="icon" class="notion-page-icon">
{{ icon }}
</span>
<DefaultPageIcon class="notion-page-icon" v-else-if="!big"></DefaultPageIcon>
</div>
</template>
8 changes: 4 additions & 4 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@
max-height: 124px;
}

span.notion-page-icon-cover {
.notion-page-icon-cover span {
height: 78px;
width: 78px;
font-size: 78px;
Expand All @@ -582,18 +582,18 @@ span.notion-page-icon-cover {
margin-left: 0px;
}

span.notion-page-icon-offset {
.notion-page-icon-offset span {
margin-top: -42px;
}

img.notion-page-icon-cover {
.notion-page-icon-cover img {
border-radius: 3px;
width: 124px;
height: 124px;
margin: 8px;
}

img.notion-page-icon-offset {
.notion-page-icon-offset img {
margin-top: -80px;
}

Expand Down