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

APIからカラーを取得 #58

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 1 addition & 2 deletions assets/css/_var.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
$primary: #BF9D73;
$secondary: #4369D9;
$light: #359AF2;
$dark: #0F1640;
$info: #2E3C8C;
$gray: #FEFEFE;
6 changes: 3 additions & 3 deletions components/ContentsBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ export default Vue.extend({
}
.content-title {
position: relative;
color: $info;
color: $dark;
margin: 16px 0;
padding-bottom: 10px;
border-bottom: solid 3px $light;
border-bottom: solid 3px var(--secondary);

&::after {
position: absolute;
content: ' ';
display: block;
border-bottom: solid 3px $primary;
border-bottom: solid 3px var(--primary);
bottom: -3px;
width: 30%;
}
Expand Down
6 changes: 3 additions & 3 deletions components/DailyBread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ export default Vue.extend({
}

.title {
border-bottom: solid 3px $light;
border-bottom: solid 3px var(--secondary);
position: relative;
color: $info;
color: $dark;
font-size: 1.5rem;
font-weight: bold;
margin: 16px 0;
Expand All @@ -243,7 +243,7 @@ export default Vue.extend({
position: absolute;
content: ' ';
display: block;
border-bottom: solid 3px $primary;
border-bottom: solid 3px var(--primary);
bottom: -3px;
width: 30%;
}
Expand Down
3 changes: 2 additions & 1 deletion components/PageTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ export default Vue.extend({
<style scoped lang="scss">
.page-title {
position: relative;
color: $dark;
margin: 20px 0 60px;
padding-bottom: 10px;

&::after {
position: absolute;
content: ' ';
display: block;
border-bottom: 5px solid $primary;
border-bottom: 5px solid var(--primary);
bottom: -3px;
width: 50px;
}
Expand Down
13 changes: 6 additions & 7 deletions components/atoms/IconRadioButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export default Vue.extend({

<style lang="scss" scoped>
button {
border: 2px solid $primary;
border-bottom: 5px solid $primary;
border: 2px solid var(--primary);
border-bottom: 5px solid var(--primary);
background-color: #fefefe;
margin: 0 10px;
}

button.checked {
margin-top: 3px;
border-bottom: 2px solid $primary;
color: $primary;
border-bottom: 2px solid var(--primary);
color: var(--primary);
}

button.unchecked {
Expand All @@ -56,16 +56,15 @@ button.unchecked {

button:hover {
margin-top: 3px;
border: 2px solid $primary;
border-bottom: 2px solid $primary;
border: 2px solid var(--primary);
}

.text {
display: block;
}

.checked-text {
color: $primary;
color: var(--primary);
font-weight: bold;
}

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ input[type='range'] {
/* つまみ */
input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none;
background: $primary;
background: var(--primary);
width: 24px;
height: 24px;
background-size: cover;
border-radius: 50%; /* 円形に */
box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15); /* 影 */
}
</style>
</style>
6 changes: 3 additions & 3 deletions components/footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export default Vue.extend({
})
</script>

<style scoped>
<style lang="scss" scoped>
footer {
margin-top: 50px;
background-color: #0f1640;
color: #fefefe;
color: $gray;
}

.footer {
Expand Down Expand Up @@ -109,4 +109,4 @@ footer a:hover {
text-align: justify;
text-justify: inter-ideograph;
}
</style>
</style>
30 changes: 14 additions & 16 deletions components/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<div class="col-sm-7 col-12 text-sm-end text-start">
<small
>あなたが
<span class="text-primary">{{ region }}</span>
<span class="region">{{ region }}</span>
に納めた税金がどこで使われているかをお示しします</small
>
</div>
Expand All @@ -117,51 +117,49 @@ export default Vue.extend({
</script>
<style lang='scss' scoped>
.header {
background-color: $info;
background-color: var(--primary);
}

a.navbar-brand {
color: $primary;
color: $gray;
font-weight: bold;
font-size: 4.5vmin;
@media (min-width: 640px) {
font-size: 18px * 1.25;
}

&:hover {
color: #fefefe;
color: $gray;
}
}

.sub-title {
background-color: $dark;
color: $dark;
font-weight: bold;
padding: 3px 0;
border-bottom: $dark solid 3px;
padding: 5px 0;

& div {
color: #fefefe;
color: $gray;
}

.region {
color: $light;
}
}

#navbarSupportedContent a {
color: #f2f2f2;
color: $gray;
font-weight: bold;
}

#navbarSupportedContent a.active {
color: #f2f2f2;
color: $dark;
font-weight: bold;
border-bottom: $primary solid 2px;
border-bottom: $dark solid 2px;
padding-bottom: 2px;
}

#navbarSupportedContent a.active:hover {
border: none;
}

#navbarSupportedContent a:hover {
color: $primary;
color: $dark;
}
</style>
4 changes: 2 additions & 2 deletions components/molecules/IncomeSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default Vue.extend({

<style lang="scss" scoped>
.money {
color: $primary;
color: var(--primary);
font-size: 1.5em;
font-weight: bold;
}
Expand All @@ -170,4 +170,4 @@ export default Vue.extend({
#display-yearly-tax {
text-align: center;
}
</style>
</style>
14 changes: 13 additions & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@

<script lang="ts">
import Vue from 'vue'
export default Vue.extend({})
export default Vue.extend({
data() {
return {
defaultPrimary: '#BF9D73',
defaultSecondary: '#4369D9',
}
},
mounted() {
const primary = this.$store.state.regionCofogData.primaryColorCode ?? this.defaultPrimary
const secondary = this.$store.state.regionCofogData.secondaryColorCode ?? this.defaultSecondary
document.documentElement.setAttribute('style', `--primary: ${primary}; --secondary: ${secondary};`);
}
})
</script>

<style>
Expand Down
2 changes: 2 additions & 0 deletions plugins/api/COFOGAPIResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface COFOGAPIResponse {
slug: string
latitude: number
longitude: number
primaryColorCode: string | null
secondaryColorCode: string | null
createdAt: string
updatedAt: string
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/applicationServices/COFOGAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class COFOGAPIService {
year: apiResponse.year,
governmentName: apiResponse.government.name,
budgetName: apiResponse.sourceBudget.name,
primaryColorCode: apiResponse.government.primaryColorCode,
secondaryColorCode: apiResponse.government.secondaryColorCode,
}
} catch (e) {
throw new Error('APIレスポンスをオブジェクトに変換失敗')
Expand Down
5 changes: 5 additions & 0 deletions plugins/dataTransferObjects/cofogData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ export type CofogData = Readonly<{
* 予算名称
*/
budgetName: string
/**
* カラーコード
*/
primaryColorCode: string | null
secondaryColorCode: string | null
}>
2 changes: 2 additions & 0 deletions plugins/repositories/CofogDataRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class CofogDataRepository {
budgetName: storeData.budgetName,
year: storeData.year,
governmentName: storeData.governmentName,
primaryColorCode: storeData.primaryColorCode,
secondaryColorCode: storeData.secondaryColorCode,
taxList: storeData.taxList.map((item: any) => {
return {
amount: Price.create(item.amount._value),
Expand Down
8 changes: 8 additions & 0 deletions test/api/COFOGAPIService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe('APIService', () => {
year: 2021,
governmentName: 'つくば市',
budgetName: 'つくば市YYYY年度予算',
primaryColorCode: null,
secondaryColorCode: null,
taxList: [
{
cofog: new Cofog(
Expand Down Expand Up @@ -89,6 +91,8 @@ describe('APIService', () => {
year: 2021,
governmentName: 'つくば市',
budgetName: 'つくば市YYYY年度予算',
primaryColorCode: null,
secondaryColorCode: null,
taxList: [
{
cofog: new Cofog(
Expand Down Expand Up @@ -217,6 +221,8 @@ const response: COFOGAPIResponse = {
slug: 'tsukuba-shi',
latitude: 36.0825081,
longitude: 140.1107132,
primaryColorCode: null,
secondaryColorCode: null,
createdAt: '2022-02-04T15:47:03.420321Z',
updatedAt: '2022-02-04T15:47:03.425683Z',
},
Expand Down Expand Up @@ -307,6 +313,8 @@ const responseMultiRecords: COFOGAPIResponse = {
slug: 'tsukuba-shi',
latitude: 36.0825081,
longitude: 140.1107132,
primaryColorCode: null,
secondaryColorCode: null,
createdAt: '2022-02-04T15:47:03.420321Z',
updatedAt: '2022-02-04T15:47:03.425683Z',
},
Expand Down
2 changes: 2 additions & 0 deletions test/applicationServices/TaxApplicationService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const inputCofogData = {
year: 2021,
governmentName: 'つくば市',
budgetName: 'つくば市YYYY年度予算',
primaryColorCode: null,
secondaryColorCode: null,
taxList: [
{
amount: Price.create(8000),
Expand Down
2 changes: 2 additions & 0 deletions test/domainServices/TaxService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ describe('TaxService', () => {
year: 2021,
governmentName: 'つくば市',
budgetName: 'つくば市YYYY年度予算',
primaryColorCode: null,
secondaryColorCode: null,
taxList: [
{
amount: Price.create(8000),
Expand Down
2 changes: 2 additions & 0 deletions test/repositories/CofogRepository.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('CofogRepository', () => {
slug: 'tsukuba-shi',
latitude: 36.0825081,
longitude: 140.1107132,
primaryColorCode: null,
secondaryColorCode: null,
createdAt: '2022-02-04T15:47:03.420321Z',
updatedAt: '2022-02-04T15:47:03.425683Z',
},
Expand Down
4 changes: 4 additions & 0 deletions test/store/CofogStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ describe('CofogVuex', () => {
year: 2021,
governmentName: 'つくば市',
budgetName: 'つくば市YYYY年度予算',
primaryColorCode: null,
secondaryColorCode: null,
taxList: [
{
amount: Price.create(27738407000.0),
Expand Down Expand Up @@ -90,6 +92,8 @@ const response: COFOGAPIResponse = {
slug: 'tsukuba-shi',
latitude: 36.0825081,
longitude: 140.1107132,
primaryColorCode: null,
secondaryColorCode: null,
createdAt: '2022-02-04T15:47:03.420321Z',
updatedAt: '2022-02-04T15:47:03.425683Z',
},
Expand Down