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

Tıklanabilir Hâl Butonları #7 #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 42 additions & 13 deletions components/Element.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default {
const selectedTemperatureType = this.$store.state.selectedTemperatureType
const temperature = this.$store.state.temperature

if (isTemperatureTriggered && this.element.number) {
let currentPhaseOfElement
if ((isTemperatureTriggered && this.element.number) || this.selectedPhaseOfElement) {
let ref
if (selectedTemperatureType === 'c') {
ref = temperature + 273.15
Expand All @@ -88,22 +89,50 @@ export default {
}

if (this.element.boil_use === '' && this.element.melt_use === '') {
return 'element-searched orange'
}
if (this.element.boil_use === '') {
return ref >= this.element.melt_use ? 'element-searched orange' : 'element-searched purple'
}
if (this.element.melt_use === '') {
return ref >= this.element.boil_use ? 'element-searched teal' : 'element-searched orange'
}
if (ref >= this.element.boil_use) {
return 'element-searched teal'
currentPhaseOfElement = 'unknown'
} else if (this.element.boil_use === '') {
currentPhaseOfElement = ref >= this.element.melt_use ? 'unknown' : 'solid'
} else if (this.element.melt_use === '') {
currentPhaseOfElement = ref >= this.element.boil_use ? 'gas' : 'unknown'
} else if (ref >= this.element.boil_use) {
currentPhaseOfElement = 'gas'
} else if (ref >= this.element.melt_use) {
return 'element-searched blue'
currentPhaseOfElement = 'liquid'
} else {
return 'element-searched purple'
currentPhaseOfElement = 'solid'
}
}

const selectedPhaseOfElement = this.$store.state.selectedPhaseOfMatter
if (selectedPhaseOfElement) {
if (selectedPhaseOfElement === currentPhaseOfElement) {
switch (currentPhaseOfElement) {
case 'solid':
return 'element-searched purple'
case 'liquid':
return 'element-searched blue'
case 'gas':
return 'element-searched teal'
case 'unknown':
return 'element-searched orange'
}
}
return null
}

if (isTemperatureTriggered && this.element.number) {
switch (currentPhaseOfElement) {
case 'solid':
return 'element-searched purple'
case 'liquid':
return 'element-searched blue'
case 'gas':
return 'element-searched teal'
case 'unknown':
return 'element-searched orange'
}
}

if (this.isFoundOnSearch || this.element.block === this.selectedBlock || this.selectedCategory === this.element.type || this.$store.getters.probableElements.includes(this.element.symbol)) {
return `element-searched ${this.element.searchClass}`
} else if (this.isFoundOnSearch === false) {
Expand Down
32 changes: 24 additions & 8 deletions components/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@
</div>
</client-only>
<div class="slider-box-wrapper">
<div>
<div class="slider-box purple">
<div @click="phaseFilter('solid')">
<div class="slider-box purple" name="solid" :class="{ gray: filterPhase('solid') }">
<img width="18" height="16" src="~/assets/icons/solid.svg" />
</div>
<div class="title">Katı</div>
</div>
<div style="margin-left: 30px">
<div class="slider-box blue">
<div style="margin-left: 30px" @click="phaseFilter('liquid')">
<div class="slider-box blue" name="liquid" :class="{ gray: filterPhase('liquid') }">
<img width="20" height="19" src="~/assets/icons/liquid.svg" />
</div>
<div class="title">Sıvı</div>
</div>
<div style="margin-left: 30px">
<div class="slider-box teal">
<div style="margin-left: 30px" @click="phaseFilter('gas')">
<div class="slider-box teal" name="gas" :class="{ gray: filterPhase('gas') }">
<img width="20" height="16" src="~/assets/icons/gas.svg" />
</div>
<div class="title">Gaz</div>
</div>
<div style="margin-left: 30px">
<div class="slider-box orange">
<div style="margin-left: 30px" @click="phaseFilter('unknown')">
<div class="slider-box orange" name="unkown" :class="{ gray: filterPhase('unknown') }">
<img width="13" height="20" src="~/assets/icons/undefined.svg" />
</div>
<div class="title">Belirsiz</div>
Expand Down Expand Up @@ -89,6 +89,11 @@ export default {
return 12632
}
},
filterPhase() {
return (state) => {
return this.$store.state.selectedPhaseOfMatter !== state && this.$store.state.selectedPhaseOfMatter !== null
}
},
},
watch: {
'$store.state.temperature': {
Expand Down Expand Up @@ -146,6 +151,12 @@ export default {
triggerTimer() {
this.$store.commit('DEACTIVATE_TEMPERATURE')
},
phaseFilter(type) {
if (type === this.$store.state.selectedPhaseOfMatter) {
type = null
}
this.$store.commit('SET_PHASE_OF_MATTER', type)
},
},
}
</script>
Expand Down Expand Up @@ -199,6 +210,7 @@ export default {
margin-top: 23px;
text-align: center;
.slider-box {
cursor: pointer;
width: 2.3vw;
height: 2.3vw;
border-radius: 4px;
Expand All @@ -224,6 +236,10 @@ export default {
box-shadow: 0 2px 40px 0 rgba(255, 175, 128, 0.4);
background-image: linear-gradient(135deg, #ffaf80, #ed954b 100%);
}
.gray {
box-shadow: 0 2px 40px 0 rgba(55, 55, 55, 0.4) !important;
background-image: linear-gradient(135deg, #3a3a3a, #38322d 100%) !important;
}
.title {
font-size: 10px;
color: $gray;
Expand Down
3 changes: 3 additions & 0 deletions store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ export default {
SET_IS_ORIENTED(state, isOriented) {
state.isOriented = isOriented
},
SET_PHASE_OF_MATTER(state, phaseOfMatter) {
state.selectedPhaseOfMatter = phaseOfMatter
},
}
1 change: 1 addition & 0 deletions store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export default () => ({
searchText: null,
isMobile: false,
isOriented: false,
selectedPhaseOfMatter: null,
})