horarios-v3/src/BarraSuperior.tsx

108 lines
3.2 KiB
TypeScript
Raw Normal View History

2021-03-26 02:39:34 +00:00
import { estilosGlobales } from "./Estilos"
import { StyleSheet, css } from "aphrodite"
import { numWallpaper, setNumWallpaper } from "./Store"
2021-01-14 23:24:55 +00:00
const ultimoIndiceWallpaper = 5
2021-01-14 23:24:55 +00:00
2021-03-01 21:38:39 +00:00
const e = StyleSheet.create({
contCambiador: {
2021-03-26 02:39:34 +00:00
userSelect: "none",
2021-03-01 21:38:39 +00:00
},
boton: {
cursor: "pointer",
textDecoration: "underline",
"::before": {
fontSize: "1rem",
2021-03-26 02:39:34 +00:00
transform: "translateY(0.2rem)",
},
2021-03-01 21:38:39 +00:00
},
botonDesactivado: {
cursor: "not-allowed",
2021-03-26 02:39:34 +00:00
textDecoration: "none",
2021-03-01 21:38:39 +00:00
},
botonLeft: {
paddingRight: "0.5rem",
2021-03-26 02:39:34 +00:00
marginRight: "0.25rem",
2021-03-01 21:38:39 +00:00
},
botonRight: {
paddingLeft: "0.5rem",
2021-03-26 02:39:34 +00:00
marginRight: "0.25rem",
},
})
2021-01-14 23:24:55 +00:00
2021-03-01 21:38:39 +00:00
const retrocederWallpaper = () => {
2021-03-26 02:39:34 +00:00
const num = numWallpaper()
2021-03-01 21:38:39 +00:00
if (num > 0) {
2021-03-26 02:39:34 +00:00
setNumWallpaper(num - 1)
localStorage.setItem("num-img", (num - 1).toString())
2021-03-01 21:38:39 +00:00
} else {
setNumWallpaper(ultimoIndiceWallpaper)
localStorage.setItem("num-img", (ultimoIndiceWallpaper).toString())
2021-03-01 21:38:39 +00:00
}
2021-03-26 02:39:34 +00:00
}
2021-01-14 23:24:55 +00:00
2021-03-01 21:38:39 +00:00
const avanzarWallpaper = () => {
2021-03-26 02:39:34 +00:00
const num = numWallpaper()
if (num < ultimoIndiceWallpaper) {
2021-03-26 02:39:34 +00:00
setNumWallpaper(num + 1)
localStorage.setItem("num-img", (num + 1).toString())
2021-03-01 21:38:39 +00:00
} else {
2021-03-26 02:39:34 +00:00
setNumWallpaper(0)
localStorage.setItem("num-img", (0).toString())
2021-03-01 21:38:39 +00:00
}
2021-03-26 02:39:34 +00:00
}
2021-01-14 23:24:55 +00:00
2021-03-01 21:38:39 +00:00
function CambiadorImg() {
2021-03-26 02:39:34 +00:00
return (
<div className={css(estilosGlobales.inlineBlock, e.contCambiador)}>
<span className={css(estilosGlobales.contenedor, estilosGlobales.inlineBlock)}>
<i
className={`ph-arrow-left ${css(e.boton, e.botonLeft, estilosGlobales.contenedorCursorSoft)}`}
onClick={retrocederWallpaper}
title={"Cambiar imagen de fondo"}
/>
Img. {numWallpaper() + 1}
<i
className={`ph-arrow-right ${css(e.boton, e.botonRight, estilosGlobales.contenedorCursorSoft)}`}
onClick={avanzarWallpaper}
title={"Cambiar imagen de fondo"}
/>
</span>
</div>
)
2021-01-14 23:24:55 +00:00
}
2021-03-03 13:27:21 +00:00
const estilos = StyleSheet.create({
tituloPrincipal: {
2021-03-26 02:39:34 +00:00
fontWeight: "bold",
},
})
2021-01-14 23:24:55 +00:00
2021-03-03 13:27:21 +00:00
export function BarraSuperior() {
2021-03-26 02:39:34 +00:00
return (
<header>
<span className={css(
estilosGlobales.contenedor,
estilosGlobales.inlineBlock,
estilos.tituloPrincipal,
)}
>
Horarios Unsa
</span>
<a href="https://github.com/Araozu/horarios-unsa-2/" target="_blank" title={"Ver codigo fuente en GitHub"}
className={css(
estilosGlobales.contenedor,
estilosGlobales.inlineBlock,
estilosGlobales.contenedorCursor,
)}
>
GitHub
<i class="ph-arrow-up-right" />
</a>
<CambiadorImg />
2021-03-28 23:40:39 +00:00
<span className={css(estilosGlobales.contenedor, estilosGlobales.inlineBlock)}>2021-A</span>
2021-03-26 02:39:34 +00:00
<span className={css(estilosGlobales.contenedor, estilosGlobales.inlineBlock)}>Ingeniería de Sistemas</span>
</header>
)
2021-01-14 23:24:55 +00:00
}