First attempt at clock styling

This commit is contained in:
James Lyne 2020-12-12 19:09:38 +00:00
parent a04df4cb09
commit 9caec78200
7 changed files with 93 additions and 145 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1,48 +1,27 @@
<script lang="ts"> <script lang="ts">
import {defineComponent, computed} from "@vue/runtime-core"; import {defineComponent, computed, watch, onMounted, onUnmounted} from "@vue/runtime-core";
import {useStore} from "@/store"; import {useStore} from "@/store";
import L from 'leaflet';
import {ClockControl, ClockControlOptions} from "@/leaflet/control/ClockControl"; import {ClockControl, ClockControlOptions} from "@/leaflet/control/ClockControl";
import DynmapMap from "@/leaflet/DynmapMap";
export default defineComponent({ export default defineComponent({
props: { props: {
leaflet: { leaflet: {
type: Object as () => L.Map, type: Object as () => DynmapMap,
required: true, required: true,
} }
}, },
setup() { setup(props) {
const store = useStore(), const store = useStore(),
componentSettings = store.state.components.clockControl, componentSettings = store.state.components.clockControl,
worldState = computed(() => store.state.currentWorldState), worldState = computed(() => store.state.currentWorldState),
control = new ClockControl(componentSettings as ClockControlOptions) as ClockControl; control = new ClockControl(componentSettings as ClockControlOptions) as ClockControl;
return { watch(worldState, (newValue) => control.update(newValue), { deep: true });
control,
worldState
}
},
watch: { onMounted(() => props.leaflet.addControl(control));
worldState: { onUnmounted(() => props.leaflet.removeControl(control));
handler(newValue) {
if (this.control) {
this.control.update(newValue);
}
},
deep: true,
}
},
mounted() {
this.leaflet.addControl(this.control);
// console.log('Mounted coordinatesControl');
},
unmounted() {
this.leaflet.removeControl(this.control);
// console.log('Unmounted coordinatesControl');
}, },
render() { render() {
@ -50,7 +29,3 @@ export default defineComponent({
} }
}) })
</script> </script>
<style scoped>
</style>

View File

@ -19,9 +19,8 @@ export class ClockControl extends L.Control {
private _weather?: HTMLElement; private _weather?: HTMLElement;
constructor(options: ClockControlOptions) { constructor(options: ClockControlOptions) {
super(options); super(Object.assign(options, {position: 'topcenter'}));
options.position = 'topleft';
L.Util.setOptions(this, options); L.Util.setOptions(this, options);
} }

View File

@ -32,6 +32,7 @@
flex-direction: column; flex-direction: column;
padding: 1.5rem; padding: 1.5rem;
position: relative; position: relative;
box-shadow: 0 0 1.5rem 0 #121212;
h2:first-child { h2:first-child {
margin-top: 0; margin-top: 0;

View File

@ -160,6 +160,17 @@
} }
} }
.leaflet-center {
left: 0;
right: 0;
justify-content: center;
flex-direction: row;
.leaflet-control {
margin: 0;
}
}
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
width: 5rem; width: 5rem;
height: 5rem; height: 5rem;

View File

@ -138,95 +138,54 @@ button {
border-radius: 0 0 3px 3px; border-radius: 0 0 3px 3px;
} }
/******************* .largeclock {
* sidebar panels @extend %panel;
*/ position: relative;
width: 15rem;
height: 6rem;
/*******************
* Sidebar clock style
*/
/*
.dynmap .clock {
display: inline-block;
height: 16px;
z-index: 50; z-index: 50;
font-weight: bold;
background-repeat: no-repeat;
padding-left: 20px;
margin-left: 8px;
}
*/
.largeclock.digitalclock {
text-align: center;
font-size: 50px;
font-weight: bold;
}
.digitalclock { .digitalclock {
text-align: center; text-align: center;
font-size: 20px; font-size: 2rem;
line-height: 2rem;
font-weight: bold; font-weight: bold;
}
.digitalclock.night { &.night {
/* background-image: url(../assets/images/clock_night.png); */
color: #dff; color: #dff;
} }
.digitalclock.day { &.day {
/* background-image: url(../assets/images/clock_day.png); */
color: #fd3; color: #fd3;
} }
.digitalclock.night, .digitalclock.day { &.night, &.day {
transition: color 8s 8s linear; transition: color 8s 8s linear;
} }
/*******************
* Large clock style
*/
.largeclock {
position: absolute;
top: 0;
left: 0;
right: 0;
border-color: rgba(0,0,0,0.5);
width: 150px;
height: 60px;
background: rgba(0,0,0,0.6);
z-index:50;
margin: auto;
} }
.timeofday { .timeofday {
background-repeat: no-repeat; background-repeat: no-repeat;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
&.digitalclock {
top: auto;
bottom: 0.5rem;
} }
.timeofday.sun { &.sun {
background-image: url(../assets/images/sun.png); background-image: url(../assets/images/sun.png);
} }
.timeofday.moon { &.moon {
background-image: url(../assets/images/moon.png); background-image: url(../assets/images/moon.png);
} }
.timeofday.digitalclock {
position: relative;
bottom: 25px;
} }
/*******************
* Clock weather style
*/
.weather { .weather {
position: absolute; position: absolute;
top: 5px; top: 5px;
@ -235,29 +194,32 @@ button {
height: 32px; height: 32px;
display: block; display: block;
background-repeat: no-repeat; background-repeat: no-repeat;
}
.weather.sunny_day { &.sunny_day {
background-image: url(../assets/images/weather_sunny_day.png); background-image: url(../assets/images/weather_sunny_day.png);
} }
.weather.stormy_day { &.stormy_day {
background-image: url(../assets/images/weather_stormy_day.png); background-image: url(../assets/images/weather_stormy_day.png);
} }
.weather.thunder_day {
&.thunder_day {
background-image: url(../assets/images/weather_thunder_day.png); background-image: url(../assets/images/weather_thunder_day.png);
} }
.weather.sunny_night { &.sunny_night {
background-image: url(../assets/images/weather_sunny_night.png); background-image: url(../assets/images/weather_sunny_night.png);
} }
.weather.stormy_night { &.stormy_night {
background-image: url(../assets/images/weather_stormy_night.png); background-image: url(../assets/images/weather_stormy_night.png);
} }
.weather.thunder_night {
&.thunder_night {
background-image: url(../assets/images/weather_thunder_night.png); background-image: url(../assets/images/weather_thunder_night.png);
} }
}
}
/******************* /*******************
* players on the map * players on the map