Skip to content

Commit

Permalink
feat: add property mode in CCard
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsPierre committed Apr 26, 2024
1 parent f579709 commit 14fa39e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/components/CCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ const props = withDefaults(
*/
subtitle?: string;
/**
* The mode how this `CCard` is used.
*/
mode?: "default" | "bottom-sheet";
/**
* Whether vertical padding should be applied to the content inside the card when the content is scrollable.
*
Expand Down Expand Up @@ -194,6 +199,7 @@ const props = withDefaults(
titleSize: "normal",
wrapTitle: undefined,
subtitle: undefined,
mode: "default",
scrollingContentVerticalPadding: true,
height: undefined,
width: "100%",
Expand All @@ -208,16 +214,21 @@ const props = withDefaults(
const cardTextComponent = ref<VCardText>();
const cardClass = computed<string>(() => {
let classes = "";
if (props.mode === "bottom-sheet")
classes += " c-card--variant--bottom-sheet";
if (
contentScrollable.value ||
slots["content-full-width"] ||
slots.actions ||
slots["prepend-actions"]
!contentScrollable.value &&
!slots["content-full-width"] &&
!slots.actions &&
!slots["prepend-actions"]
) {
return "";
classes += " pb-6 pb-md-8";
}
return "pb-6 pb-md-8";
return classes;
});
/**
Expand Down Expand Up @@ -278,6 +289,11 @@ const emit = defineEmits<{
@import "vuetify/lib/styles/settings/variables";
.c-card {
&.c-card--variant--bottom-sheet {
border-bottom-left-radius: 0 !important;
border-bottom-right-radius: 0 !important;
}
& > .v-card-text > * {
&:not(:last-child) {
margin-bottom: 12px !important;
Expand Down
22 changes: 22 additions & 0 deletions stories/CCard.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const meta: Meta<typeof CCard> = {
subtitle: {
control: "text",
},
mode: {
control: "radio",
options: ["default", "bottom-sheet"],
},
scrollingContentVerticalPadding: {
control: "boolean",
},
Expand Down Expand Up @@ -183,6 +187,24 @@ export const Closable: Story = {
}),
};

export const VariantBottomSheet: Story = {
args: {
title: "Card for a BottomSheet",
mode: "bottom-sheet",
},
render: createStorybookRender({
components: { CCard },
template: `
<c-card v-bind='args' class="ma-5">
Cards main content.
</c-card>
`,
}),
parameters: createStorybookParameters({
slotTemplate: "Cards main content.",
}),
};

export const ContentFullWidth: Story = {
args: {
title: "Card content with full list",
Expand Down

0 comments on commit 14fa39e

Please sign in to comment.