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

feat: support transparent background #42

Merged
merged 1 commit into from
Aug 8, 2024
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
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"Corners Square type": "Corners Square type",
"Corners Dot color": "Corners Dot color",
"Corners Dot type": "Corners Dot type",
"With background": "With background",
"QR code preset": "QR code preset",
"Preset": "Preset",
"dots": "dots",
Expand Down
28 changes: 27 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ const cornersDotOptionsType = ref()
const styleBorderRadius = ref()
const styledBorderRadiusFormatted = computed(() => `${styleBorderRadius.value}px`)
const styleBackground = ref(defaultPreset.style.background)
const lastBackground = ref(defaultPreset.style.background)

const withBackground = ref(true)
watch(withBackground, () => {
if (!withBackground.value) {
lastBackground.value = styleBackground.value
styleBackground.value = 'transparent'
} else {
styleBackground.value = lastBackground.value
}
})

const dotsOptions = computed(() => ({
color: dotsOptionsColor.value,
Expand Down Expand Up @@ -592,7 +603,22 @@ onMounted(() => {
v-model="image"
/>
</div>
<div id="color-settings" class="flex w-full flex-row flex-wrap gap-4">
<div class="flex flex-row items-center gap-2">
<label for="with-background">
{{ t('With background') }}
</label>
<input
id="with-background"
type="checkbox"
class="checkbox"
v-model="withBackground"
/>
</div>
<div
id="color-settings"
:inert="!withBackground"
:class="[!withBackground && 'opacity-30', 'flex w-full flex-row flex-wrap gap-4']"
>
<div class="flex flex-row items-center gap-2">
<label for="background-color">{{ t('Background color') }}</label>
<input
Expand Down
Loading