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

RadioButtonとRadioCardの実装 #57

Merged
merged 20 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 19 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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="@/main.ts"></script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions src/pages/registerView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<div :class="$style.wrapper">
<div :class="$style.container">
<div :class="$style.itemA">A</div>
<div :class="$style.itemB">B</div>
<div :class="$style.itemC">C</div>
</div>
</div>
<radio-card
title="選択肢"
content="選択肢選択肢選択肢選択肢選択肢選択肢選択肢選択肢"
name="a"
value="a"
/>
</template>

<script setup lang="ts">
import RadioCard from '@/shared/components/RadioCard.vue';
</script>

<style lang="scss" module>
.wrapper {
display: flex;
justify-content: center;
padding: 50px 0;
}

.container {
display: grid;
width: 1024px;
padding: 32px;
grid-template-rows: 200px 120px;
grid-template-columns: 160px 160px 160px 160px 160px 160px;
border: 1px solid red;
}
.itemA {
border: 1px solid orange;
grid-column: 1 / span 3;
}
.itemB {
border: 1px solid blue;
grid-column: 4 / span 3;
}
.itemC {
border: 1px solid green;
grid-column: 1 / span 2;
padding-top: 32px;
}
</style>
6 changes: 6 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { RouteRecordRaw } from 'vue-router';
import { createRouter, createWebHistory } from 'vue-router';
import registerView from '@/pages/registerView.vue';

export const routerHistory = createWebHistory();

Expand All @@ -9,6 +10,11 @@ const routes: RouteRecordRaw[] = [
name: 'Dashboard',
component: () => import('@/pages/DashBoard.vue'),
},
{
path: '/register',
name: 'register',
component: registerView,
},
];

export default createRouter({
Expand Down
120 changes: 120 additions & 0 deletions src/shared/components/RadioCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<template>
<label>
<input
:class="$style.input"
type="radio"
:name="props.name"
:value="props.value"
@change="model = props.value"
/>
<div :class="$style.container">
<div :class="$style.title_wrapper">
<div :class="$style.title">{{ props.title }}</div>
<div :class="$style.btn"></div>
</div>
<div :class="$style.content">
{{ props.content }}
</div>
</div>
</label>
</template>

<script lang="ts" setup>
const props = defineProps<{
title: string;
content: string;
name: string;
value: string;
}>();

const model = defineModel<string>();
</script>

<style lang="scss" module>
.container {
box-shadow: inset 0 0 0 1px $color-secondary;
border-radius: 4px;
display: flex;
padding: 16px;
flex-direction: column;
align-items: flex-start;
gap: 8px;
cursor: pointer;
}

.container:hover {
background-color: $color-primary-hover;
}

.input:checked + .container {
box-shadow: inset 0 0 0 3px $color-primary;
}

.title_wrapper {
display: flex;
justify-content: space-between;
align-items: center;
align-self: stretch;
}

.title {
color: $color-text-primary;
font-size: 16px;
font-style: normal;
font-weight: 700;
line-height: normal;
}

.content {
font-size: 16px;
text-align: left;
align-self: stretch;
color: $color-text-dimmed;
font-size: 16px;
font-weight: 500;
line-height: normal;
}

.input {
display: none;
}

.btn {
cursor: pointer;
position: relative;
width: 24px;
height: 24px;
flex-shrink: 0;
}

.btn::before {
content: '';
width: 100%;
height: 100%;
border-radius: 50%;
background-color: $color-container-secondary;
border: 2px solid $color-secondary;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
z-index: 10;
box-sizing: border-box;
}

.input:checked + .container .title_wrapper .btn::before {
background-color: $color-primary;
border: none;
}

.input:checked + .container .title_wrapper .btn::after {
content: '';
width: 50%;
height: 50%;
border-radius: 50%;
background-color: $color-background;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
z-index: 11;
}
</style>
7 changes: 5 additions & 2 deletions src/styles/common.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use 'sass:math';

$color-primary: #5cb860;
$color-primary-hover: #7fc782;
$color-primary-hover: #eef7ee;
$color-primary-disabled: #a9d0ab;

$color-secondary: #e2e2e2;
Expand All @@ -10,12 +10,15 @@ $color-secondary-disabled: #c9cac9;

$color-error: #ff4500;

$color-text-primary: #2b2b2b;
$color-text-primary: #1a1a1c;
$color-text-primary-disabled: #7a7a7a;
$color-text-secondary: #515151;
$color-text-secondary-pale: #5151515d;
$color-text-secondary-disabled: #939393;
$color-text-white: #ffffff;
$color-text-dimmed: #626264;

$color-container-secondary: #f1f1f4;

$color-background: #ffffff;
$color-background-dim: #2b2b2baa;
Expand Down
Loading