-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from Holo-Host/feature/happ-paid-free-option
feat(hosting-plan): implement radio buttons and modals
- Loading branch information
Showing
9 changed files
with
524 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
const props = defineProps<{ | ||
id: string | ||
value: string | ||
label: string | ||
description: string | ||
modelValue: string | ||
}>() | ||
const emit = defineEmits(['update:modelValue']) | ||
const localValue = ref(props.modelValue) | ||
</script> | ||
|
||
<template> | ||
<div class="base-radio-button__wrapper"> | ||
<label | ||
class="base-radio-button__button" | ||
for="html" | ||
data-ripple-dark="true" | ||
> | ||
<input | ||
:id="props.id" | ||
v-model="localValue" | ||
name="type" | ||
type="radio" | ||
:value="props.value" | ||
class="base-radio-button__input" | ||
@change="emit('update:modelValue', props.value)" | ||
/> | ||
<div class="base-radio-button__input-inner"> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 16 16" | ||
fill="currentColor" | ||
> | ||
<circle | ||
data-name="ellipse" | ||
cx="8" | ||
cy="8" | ||
r="8" | ||
></circle> | ||
</svg> | ||
</div> | ||
</label> | ||
|
||
<div class="base-radio-button__labels"> | ||
<label | ||
class="base-radio-button__label" | ||
:for="props.id" | ||
> | ||
{{ props.label }} | ||
</label> | ||
|
||
<label | ||
class="base-radio-button__description" | ||
:for="props.id" | ||
> | ||
{{ props.description }} | ||
</label> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.base-radio-button { | ||
&__wrapper { | ||
display: inline-flex; | ||
align-items: start; | ||
} | ||
&__button { | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
border-radius: 9999px; | ||
padding: 0; | ||
margin-top: 2px; | ||
} | ||
&__input { | ||
position: relative; | ||
height: 15px; | ||
width: 15px; | ||
cursor: pointer; | ||
appearance: none; | ||
border-radius: 9999px; | ||
border: 1px solid var(--grey-dark-color); | ||
&:checked { | ||
border-color: var(--primary-color); | ||
background-color: rgba(0, 202, 217, 0.15); | ||
& + .base-radio-button__input-inner { | ||
opacity: 1; | ||
} | ||
} | ||
&-inner { | ||
position: absolute; | ||
pointer-events: none; | ||
left: 3px; | ||
top: -2px; | ||
color: var(--primary-color); | ||
opacity: 0; | ||
height: 9px; | ||
width: 9px; | ||
} | ||
} | ||
&__labels { | ||
display: flex; | ||
flex-direction: column; | ||
margin-left: 8px; | ||
} | ||
&__label { | ||
font-weight: 800; | ||
cursor: pointer; | ||
} | ||
&__description { | ||
font-weight: 600; | ||
font-size: 12px; | ||
color: var(--grey-light-color); | ||
cursor: pointer; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
import BaseRadioButton from '@/components/BaseRadioButton.vue' | ||
import HostingPlanModal from '@/components/modals/HostingPlanModal.vue' | ||
import type { HAppDetails } from '@/interfaces/HposInterface' | ||
const { t } = useI18n() | ||
const props = defineProps<{ | ||
hApp: HAppDetails | ||
}>() | ||
const emit = defineEmits(['update:hosting-plan']) | ||
const planValue = ref<'free' | 'paid'>(props.hApp.hostingPlan) | ||
const isModalVisible = ref(false) | ||
function openModal(): void { | ||
isModalVisible.value = true | ||
} | ||
function closeModal(): void { | ||
isModalVisible.value = false | ||
} | ||
function showConfirmation(value: 'free' | 'paid'): void { | ||
planValue.value = value | ||
openModal() | ||
} | ||
function updatePlan(value: 'free' | 'paid'): void { | ||
planValue.value = value | ||
emit('update:hosting-plan', value) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="happ-details-hosting-plan"> | ||
<span class="happ-details-hosting-plan__title">{{ t('happ_details.hosting_plan.label') }}</span> | ||
<div class="happ-details-hosting-plan__radio-buttons"> | ||
<BaseRadioButton | ||
id="happ-details-hosting-plan-paid" | ||
:key="planValue" | ||
value="paid" | ||
:model-value="planValue" | ||
:label="t('happ_details.hosting_plan.paid')" | ||
:description="t('happ_details.hosting_plan.paid_description')" | ||
class="happ-details-hosting-plan__radio-button-paid" | ||
@update:model-value="showConfirmation" | ||
/> | ||
|
||
<BaseRadioButton | ||
id="happ-details-hosting-plan-free" | ||
:key="planValue" | ||
value="free" | ||
:model-value="planValue" | ||
:label="t('happ_details.hosting_plan.free')" | ||
:description="t('happ_details.hosting_plan.free_description')" | ||
class="happ-details-hosting-plan__radio-button-free" | ||
@update:model-value="showConfirmation" | ||
/> | ||
</div> | ||
|
||
<HostingPlanModal | ||
v-if="props.hApp" | ||
:h-app="props.hApp" | ||
:plan-value="planValue" | ||
:is-visible="isModalVisible" | ||
@close="closeModal" | ||
@update:hosting-plan="updatePlan" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.happ-details-hosting-plan { | ||
display: flex; | ||
flex-direction: column; | ||
&__title { | ||
font-size: 16px; | ||
font-weight: 800; | ||
} | ||
&__radio-buttons { | ||
display: flex; | ||
flex-direction: column; | ||
margin-top: 18px; | ||
} | ||
&__radio-button-free { | ||
margin-top: 12px; | ||
} | ||
} | ||
@media screen and (max-width: 1050px) { | ||
.happ-details-hosting-plan { | ||
} | ||
} | ||
</style> |
Oops, something went wrong.