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

Blockquote component #311

Merged
merged 9 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ function getUtils() {

function getTypography() {
return [
{ text: "Blockquote", link: '/components/blockquote' },
{ text: 'Heading', link: '/components/heading' },
{ text: 'Paragraph', link: '/components/paragraph' },
{ text: 'Image', link: '/components/image' },
{ text: 'Link', link: '/components/link' }

ogzcode marked this conversation as resolved.
Show resolved Hide resolved
]
}

Expand Down
87 changes: 87 additions & 0 deletions docs/components/blockquote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<script setup>
import FwbBlockquoteExample from './typography/blockquote/FwbBlockquoteExample.vue'
import FwbBlockquoteSolidExample from './typography/blockquote/FwbBlockquoteSolidExample.vue'
import FwbBlockquoteAlignExample from './typography/blockquote/FwbBlockquoteAlignExample.vue'
import FwbBlockquoteSizeExample from './typography/blockquote/FwbBlockquoteSizeExample.vue'
</script>

# Vue Blockquote - Flowbite
---

:::tip
Original reference: [https://flowbite.com/docs/typography/blockquote/](https://flowbite.com/docs/typography/blockquote/)
:::

#### Get started with a collection of blockquote components when quoting external sources such as quotes inside an article, user reviews, and testimonials based on multiple examples of layouts, styles, and contexts. Each example will demonstrate different ways to customize the blockquote using props like `size`, `align`, `type`, and `cite`.

## Default blockquote

Use this example to quote an external source inside a `<FwbBlockquote>` component.

<FwbBlockquoteExample/>
ogzcode marked this conversation as resolved.
Show resolved Hide resolved

```vue
<FwbBlockquote>
"Flowbite is just awesome. It contains tons of predesigned components and pages starting from login screen to complex dashboard.
Perfect choice for your next SaaS application."
</FwbBlockquote>
```

## Solid background
This example can be used as an alternative style to the default style by applying a solid background color with `type="solid"`.

<FwbBlockquoteSolidExample />

```vue
<FwbBlockquote type="solid">
"Flowbite is just awesome.Perfect choice for your next SaaS application."
</FwbBlockquote>
```

## Alignment

From the examples below, select the blockquote text alignment based on the `align`prop, starting from the left and moving from middle to right.

<FwbBlockquoteAlignExample align="left" />
<hr />
<br/>
<FwbBlockquoteAlignExample align="center" />
<hr />
<br/>
<FwbBlockquoteAlignExample align="right" />

```vue
<FwbBlockquote align="left">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
<FwbBlockquote align="center">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
<FwbBlockquote align="right">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
```

## Size

Choose from multiple sizes with the `size` prop for the default blockquote component based on surrounding elements and dimensions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix heading level and punctuation.

The heading level should be h2 and the trailing punctuation should be removed.

- ## Size
+ ### Size
- ## Size
+ ## Size
Tools
LanguageTool

[uncategorized] ~67-~67: Possible missing comma found.
Context: ...ote> ``` ## Size Choose from multiple sizes with the size prop for the default bl...

(AI_HYDRA_LEO_MISSING_COMMA)


<FwbBlockquoteSizeExample size="sm" />
<hr />
<br/>
<FwbBlockquoteSizeExample size="md" />
<hr />
<br/>
<FwbBlockquoteSizeExample size="lg" />

```vue
<FwbBlockquote size="sm">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
<FwbBlockquote size="md">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
<FwbBlockquote size="lg">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div class="vp-raw flex">
<FwbBlockquote :align="align">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
</div>
</template>

<script setup>
import { FwbBlockquote } from '../../../../src/index'

const props = defineProps({
align: {
type: String,
default: 'left'
}
})
</script>
11 changes: 11 additions & 0 deletions docs/components/typography/blockquote/FwbBlockquoteExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="vp-raw flex">
<FwbBlockquote>
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
</div>
</template>

<script setup>
import { FwbBlockquote } from '../../../../src/index'
</script>
ogzcode marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions docs/components/typography/blockquote/FwbBlockquoteSizeExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div class="vp-raw flex">
<FwbBlockquote :size="size">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
</div>
</template>

<script setup>
import { FwbBlockquote } from '../../../../src/index'

const props = defineProps({
size: {
type: String,
default: 'md'
}
})

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="vp-raw flex">
<FwbBlockquote type="solid">
"Flowbite is just awesome. Perfect choice for your next SaaS application."
</FwbBlockquote>
</div>
</template>

<script setup>
import { FwbBlockquote } from '../../../../src/index'
</script>
ogzcode marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions src/components/FwbBlockquote/FwbBlockquote.vue
ogzcode marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<blockquote :class="blockquoteClasses" :cite="cite">
<slot></slot>
</blockquote>
</template>

<script lang="ts" setup>
import { defineProps } from 'vue'
ogzcode marked this conversation as resolved.
Show resolved Hide resolved
import { useBlockquoteClasses } from './composables/useBlockquoteClasses'
import type { BlockquoteSize, BlockquoteAlign, BlockquoteType } from './types'

interface BlockquoteProps {
type?: BlockquoteType;
size?: BlockquoteSize;
align?: BlockquoteAlign;
cite?: string;
}

const props = withDefaults(defineProps<BlockquoteProps>(), {
type: 'default',
size: 'md',
align: 'left',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size and alignment should be changed just by overriding tailwind classes... and not by dedicated props.

(again, take a look at src/components/Typography/FwbP.vue to see how it's done there)

cite: '',
})

const {
blockquoteClasses
} = useBlockquoteClasses(props)
</script>
40 changes: 40 additions & 0 deletions src/components/FwbBlockquote/composables/useBlockquoteClasses.ts
ogzcode marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { BlockquoteSize, BlockquoteAlign, BlockquoteType } from "../types";
import { computed, ref, useAttrs } from "vue";
import { twMerge } from "tailwind-merge";

const defaultBlockquoteClasses = "font-semibold italic text-gray-900 dark:text-white";
const blockquoteAlignClasses: Record<BlockquoteAlign, string> = {
left: "text-left",
center: "text-center",
right: "text-right",
};
const blockquoteSizeClasses: Record<BlockquoteSize, string> = {
sm: "text-lg",
md: "text-xl",
lg: "text-2xl",
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as stated above... this should be achieved by tailwind classes directly on the component


export type UseBlockquoteClassesProps = {
size: BlockquoteSize;
align: BlockquoteAlign;
type: BlockquoteType;
};

export function useBlockquoteClasses(
props: UseBlockquoteClassesProps
) {
const attrs = useAttrs();
const blockquoteClasses = computed(() => {
return twMerge(
blockquoteSizeClasses[props.size],
blockquoteAlignClasses[props.align],
props.type === "solid" ? "bg-gray-100 dark:bg-gray-800 border-l-4 border-gray-300 p-4 dark:border-gray-500" : "",
defaultBlockquoteClasses,
attrs.class as string
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have dedicated composable fot this src/components/Typography/FwbP.vue has a simple use case example

});

return {
blockquoteClasses,
};
}
3 changes: 3 additions & 0 deletions src/components/FwbBlockquote/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type BlockquoteType = 'default' | 'solid'
export type BlockquoteAlign = 'left' | 'center' | 'right'
export type BlockquoteSize = 'sm' | 'md' | 'lg'
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export { default as FwbA } from './components/Typography/FwbA.vue'
export { default as FwbHeading } from './components/Typography/FwbHeading.vue'
export { default as FwbImg } from './components/Typography/FwbImg.vue'
export { default as FwbP } from './components/Typography/FwbP.vue'
export { default as FwbBlockquote } from './components/FwbBlockquote/FwbBlockquote.vue'

// utilities
export { default as FlowbiteThemable } from './components/utils/FlowbiteThemable/FlowbiteThemable.vue'
Expand Down