Skip to content

Commit 1fb7cd1

Browse files
author
Afriq Yasin Ramadhan
committed
feat: adding local variables in banner, chart and contextualbar
1 parent 2d2963f commit 1fb7cd1

10 files changed

Lines changed: 38 additions & 11 deletions

File tree

src/components/banner/Banner.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ it('should be able to add background image via slot `background-url`', () => {
164164
const banner = screen.queryByTestId('banner')
165165

166166
expect(banner).toBeInTheDocument()
167-
expect(banner).toHaveStyle({ 'background-image': 'url("assets/images/img-background-banner.svg")' })
167+
expect(banner).toHaveStyle({ '--p-banner-bg-image': 'url("assets/images/img-background-banner.svg")' })
168168
})
169169

170170
it('should be able to add background overlay via slot `background-overlay`', () => {

src/components/banner/Banner.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
v-if="show"
44
data-testid="banner"
55
:class="classNames"
6-
:style="{ 'background-image': backgroundUrl ? `url('${backgroundUrl}')`: 'none' }">
6+
:style="{ '--p-banner-bg-image' : bannerBgImage }">
77
<div
88
v-if="!noIcon"
99
class="banner__icon"
@@ -85,6 +85,8 @@ const classNames = computed(() => {
8585
return result
8686
})
8787
88+
const bannerBgImage = `url("${props.backgroundUrl}")`
89+
8890
const icon = computed(() => {
8991
return BannerIcons[props.variant]
9092
})
@@ -105,7 +107,10 @@ defineSlots<{
105107

106108
<style lang="postcss">
107109
.banner {
108-
@apply p-4 flex space-x-2 rounded text-subtle;
110+
--p-banner-padding-x: theme(spacing.4);
111+
--p-banner-padding-y: theme(spacing.4);
112+
113+
@apply px-[var(--p-banner-padding-x)] py-[var(--p-banner-padding-y)] flex space-x-2 rounded text-subtle;
109114
@apply dark:text-dark-subtle;
110115
111116
a {
@@ -124,7 +129,7 @@ defineSlots<{
124129
}
125130
126131
&&--custom-background {
127-
@apply bg-cover bg-no-repeat bg-center overflow-hidden;
132+
@apply bg-cover bg-no-repeat bg-center overflow-hidden bg-[image:var(--p-banner-bg-image)];
128133
}
129134
130135
&&--overlay {

src/components/banner/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ You can hide close button with `dismissable` set to `false`
232232
</template>
233233
```
234234

235+
## Variables
236+
Banner use local CSS variables on `.banner` for enhanced real-time customization.
237+
238+
```sass
239+
--p-banner-padding-x: theme(spacing.4);
240+
--p-banner-padding-y: theme(spacing.4);
241+
```
235242

236243
## API
237244

src/components/chart/Chart.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ onBeforeUnmount(() => {
148148

149149
<style lang="postcss">
150150
.chart {
151-
@apply w-full bg-default p-4;
151+
--p-chart-padding-x: theme(spacing.4);
152+
--p-chart-padding-y: theme(spacing.4);
153+
154+
@apply w-full bg-default px-[var(--p-chart-padding-x)] py-[var(--p-chart-padding-y)];
152155
@apply dark:bg-dark-default;
153156
}
154157
</style>

src/components/chart/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,14 @@ If renderless not satisfies your needs, you can manually set the datasets and op
517517
</script>
518518
```
519519

520+
## Variables
521+
Chart use local CSS variables on `.chart` for enhanced real-time customization.
522+
523+
```sass
524+
--p-chart-padding-x: theme(spacing.4);
525+
--p-chart-padding-y: theme(spacing.4);
526+
```
527+
520528
## API
521529

522530
### Props `<p-chart>`

src/components/contextual-bar/ContextualBar.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ it('should be able to add custom background via prop `background-url`', () => {
145145

146146
expect(bar).toBeInTheDocument()
147147
expect(bar).toHaveClass('contextual-bar--background-image')
148-
expect(bar).toHaveStyle({ 'background-image': 'url("assets/images/img-background-contextualbar.svg")' })
148+
expect(bar).toHaveStyle({ '--p-contextualbar-bg-image': 'url("assets/images/img-background-contextualbar.svg")' })
149149
})
150150

151151
it('should be able to add icon via slot `icon`', () => {

src/components/contextual-bar/ContextualBar.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class="contextual-bar"
1212
v-bind="$attrs"
1313
:class="classNames"
14-
:style="{ 'background-image': backgroundUrl ? `url('${backgroundUrl}')`: 'none' }">
14+
:style="{ '--p-contextualbar-bg-image': backgroundImageUrl }">
1515
<div
1616
data-testid="contextual-bar-wrapper"
1717
:class="[{ 'contextual-bar__wrapper--with-message' : (message || $slots.message), 'contextual-bar__wrapper--with-action' : $slots.action } ,'contextual-bar__wrapper']">
@@ -142,6 +142,10 @@ const classNames = computed(() => {
142142
return result
143143
})
144144
145+
const backgroundImageUrl = computed(() => {
146+
return `url("${props.backgroundUrl}")`
147+
})
148+
145149
function onEnter (target: HTMLDivElement) {
146150
target.style.setProperty('transform', `translateY(-${target.clientHeight}px)`)
147151
@@ -207,7 +211,7 @@ defineSlots<{
207211
* are available
208212
*/
209213
&--background-image {
210-
@apply bg-no-repeat bg-cover bg-[top_center];
214+
@apply bg-no-repeat bg-cover bg-[top_center] !bg-[image:var(--p-contextualbar-bg-image)];
211215
}
212216
213217
/**

src/components/contextual-bar/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ import IconInfo from '@privyid/persona-icon/vue/information-circle-solid/20.vue'
211211
message="You will be unable to sign or seal a document"
212212
background-url="../../public/assets/images/img-contextualbar-bg.svg">
213213
<template #icon>
214-
<img src="../avatar/assets/avatar.png" />
214+
<img src="../../public/assets/images/user.png" />
215215
</template>
216216
</p-contextual-bar>
217217
</preview>
@@ -288,7 +288,7 @@ To align Contextual Bar content, use align prop. Available value are `left`, `ri
288288
title="Hey! This is Title Text and telling less as possible"
289289
background-url="../../public/assets/images/img-contextualbar-bg.svg">
290290
<template #icon>
291-
<img src="../avatar/assets/avatar.png" />
291+
<img src="../../public/assets/images/user.png" />
292292
</template>
293293
<template #action>
294294
<p-button size="sm" color="secondary" variant="link">Cancel</p-button>

src/components/pdf-viewer/PdfNavigation.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const pages = computed<SelectItem[]>(() => {
9191
@apply flex bg-inverse text-subtlest rounded p-2 space-x-1 items-center;
9292
@apply dark:text-dark-default;
9393
94-
> .btn {
94+
> .btn.btn--variant-ghost {
9595
@apply text-subtlest hover:text-muted focus:text-muted;
9696
@apply dark:text-dark-subtle hover:dark:text-dark-default focus:dark:text-dark-default;
9797
}

src/public/assets/images/user.png

4.01 KB
Loading

0 commit comments

Comments
 (0)