Skip to content

Commit

Permalink
Merge pull request #4140 from traPtitech/feat/tertiary_form_button
Browse files Browse the repository at this point in the history
formButtonにtertiaryを追加
  • Loading branch information
mehm8128 authored Nov 5, 2023
2 parents 6b1ea3f + fc57879 commit bea3a2b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
24 changes: 21 additions & 3 deletions src/components/UI/FormButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
:data-color="color"
>
<div :class="$style.label">{{ label }}</div>
<loading-spinner v-if="loading" :class="$style.spinner" />
<loading-spinner
v-if="loading"
:class="$style.spinner"
:color="spinnerColor"
/>
</button>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import LoadingSpinner from '/@/components/UI/LoadingSpinner.vue'
withDefaults(
const props = withDefaults(
defineProps<{
label?: string
loading?: boolean
disabled?: boolean
color?: 'primary' | 'secondary' | 'error'
color?: 'primary' | 'secondary' | 'error' | 'tertiary'
}>(),
{
label: '',
Expand All @@ -27,6 +32,15 @@ withDefaults(
color: 'primary' as const
}
)
const spinnerColor = computed(() => {
switch (props.color) {
case 'tertiary':
return 'accent-primary'
default:
return 'white'
}
})
</script>

<style lang="scss" module>
Expand All @@ -52,6 +66,10 @@ withDefaults(
@include color-ui-secondary;
border-color: $theme-ui-secondary-default;
}
&[data-color='tertiary'] {
@include color-accent-primary;
border-color: $theme-accent-primary-default;
}
&[data-color='error'] {
color: $theme-accent-error-default;
border-color: $theme-accent-error-default;
Expand Down
6 changes: 5 additions & 1 deletion src/components/UI/LoadingSpinner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>

<script lang="ts" setup>
type SpinnerColor = 'white' | 'ui-secondary'
type SpinnerColor = 'white' | 'ui-secondary' | 'accent-primary'
withDefaults(
defineProps<{
Expand Down Expand Up @@ -33,6 +33,10 @@ $spinner-width: 0.35em;
--spinner-color: #{$theme-ui-secondary-default};
--spinner-gap-color: var(--specific-loading-spinner-gap-ui-secondary);
}
&[data-color='accent-primary'] {
--spinner-color: #{$theme-accent-primary-default};
--spinner-gap-color: transparent;
}
}
.spinner {
position: relative;
Expand Down

0 comments on commit bea3a2b

Please sign in to comment.