Skip to content

Commit

Permalink
tela de configuracoes arrumada e funcionando 3/4
Browse files Browse the repository at this point in the history
  • Loading branch information
Andra-sun committed Apr 26, 2024
1 parent 86a5130 commit 2751655
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 36 deletions.
3 changes: 2 additions & 1 deletion static/css/body.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ body{
font-family: "roboto", monospace;
height: 100vh;
transition: ease-in-out 0.2s;
overflow: auto;
overflow-y: auto;
overflow-x: hidden;
}
::selection {
background-color: var(--color-main);
Expand Down
66 changes: 64 additions & 2 deletions static/css/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,69 @@
flex-direction: column;
align-items: flex-start;
justify-content: left;
width: 80%;
width: 90%;
padding: 0;
margin: 0;
overflow-x: hidden;
overflow-y: auto
}
.choiceTheme{
width: 15rem;
height: 10rem;
border: 3px solid var(--color-main);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-radius: 1rem;
margin: 1rem;
cursor: pointer;
}
.choiceTheme h5{
padding: 1.8rem;
color: #fff;
}
.configConainerRow{
display: flex;
flex-direction: row;
}
.configConainerRow button{
margin-right: 30px;
border: none;
padding: 1rem;
overflow: hidden;
border-radius: 1rem;
cursor: pointer;
width: 10rem;
color: var(--color-fg);
font-weight: 700;
}
#autoTheme{
flex-direction: row;
background: linear-gradient(to right, #0e1120 50%, #f6f6f6 50%);

}
#autoTheme h5{
background: linear-gradient(to right, #fff 50%, #2d3242 50%);
}
#saveConfig{
background-color: var(--color-main);
width: 15rem;
}
#saveConfig:hover{
background-color: var(--color-main-hover);
}
#cancelConfig{
background-color: var(--color-bg);
border: 3px solid var(--color-main);
}
#cancelConfig:hover{
border-color: var(--color-main-hover);
}
#configNavBtn{
width: 100%;
margin-top: 4rem;
display: flex;
align-items: center;
justify-content: right;
margin-right: 4rem;
}
59 changes: 48 additions & 11 deletions static/html/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,55 @@
<link rel="stylesheet" href="../css/config.css">
<title>Configuracoes</title>
</head>
<body>
<body data-theme="light" data-color="pink">
<div id="config">
<h3>Tema</h3>
<h6 id="darkTheme">
<h5><p>aaaa</p></h5>
</h6>
<h6 id="darkTheme">
<h5><p>aaaaa</p></h5>
</h6>
<h3>Cor</h3>
<button id="pink">Rosa</button>
<button id="b">azul</button></div>
<h3>Tema</h3>
<div class="configConainerRow">
<div class="optnT">
<div style="background-color: #0e1120;" id="darkTheme" class="choiceTheme">
<h5 style="background-color: #2d3242;"><p style="color:
#fff;">________ <br> ________<br> ________</p></h5>
</div>
<input type="radio" name="themeRadio" id="darkRadio">
<label for="darkRadio">Escuro</label>
</div>

<div class="optnT">
<div style="background-color: #f6f6f6;" id="lightTheme" class="choiceTheme">
<h5 style="background-color: #fff;"><p style="color:
#000;">________ <br> ________<br> ________</p></h5>
</div>
<input type="radio" name="themeRadio" id="lightRadio">
<label for="lightRadio">Claro</label>
</div>

<div class="optnT">
<div id="autoTheme" class="choiceTheme">
<h5><p><span style="color: #000">____</span>____<br> <span style="color: #000">____</span>____<br> <span style="color: #000">____</span>____</p></h5></h5>
</div>
<input type="radio" name="themeRadio" id="autoRadio">
<label for="autoRadio">Automatico</label>
</div>

</div>

<h3 style="margin-top: 8rem;">Cor</h3>
<div class="configConainerRow">
<button id="pink" style="background-color: rgb(255, 59, 163);">Rosa</button>
<button id="blue" style="background-color: #0ebbff;">Azul</button></div>
</div>

<div class="configConainerRow" id="configNavBtn">
<button id="saveConfig">
Salvar
</button>
<button id="cancelConfig">
Cancelar
</button>
</div>
</div>



<script src="../js/themeAndColor.js"></script>
</body>
Expand Down
57 changes: 35 additions & 22 deletions static/js/themeAndColor.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,59 @@
const body = document.body;
const toggleTheme = document.getElementById("toggleTheme");
const toggleColor = document.getElementById("toggleColor");
const darkThemeRadio = document.getElementById("darkRadio");
const lightThemeRadio = document.getElementById("lightRadio");
const autoThemeRadio = document.getElementById("autoRadio");
const pinkColorButton = document.getElementById("pink");
const blueColorButton = document.getElementById("blue");

function updateThemeBasedOnSystemPreference() {
const prefersDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
if (prefersDarkMode) {
body.setAttribute("data-theme", "dark");
toggleTheme.innerText = "Dark Theme";
} else {
body.setAttribute("data-theme", "light");
toggleTheme.innerText = "Light Theme";
}
}

function setTheme(theme) {
body.setAttribute("data-theme", theme);
}

function setColor(color) {
body.setAttribute("data-color", color);
}

updateThemeBasedOnSystemPreference();

window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => {
if (e.matches) {
body.setAttribute("data-theme", "dark");
toggleTheme.innerText = "Dark Theme";
setTheme("dark");
} else {
body.setAttribute("data-theme", "light");
toggleTheme.innerText = "Light Theme";
setTheme("light");
}
});

toggleTheme.addEventListener("click", () => {
if (body.getAttribute("data-theme") === "light") {
body.setAttribute("data-theme", "dark");
toggleTheme.innerText = "Dark Theme";
} else {
body.setAttribute("data-theme", "light");
toggleTheme.innerText = "Light Theme";
darkThemeRadio.addEventListener("change", () => {
if (darkThemeRadio.checked) {
setTheme("dark");
}
});

toggleColor.addEventListener("click", () => {
if (body.getAttribute("data-color") === "pink") {
body.setAttribute("data-color", "blue");
toggleColor.innerText = "Blue Theme";
} else {
body.setAttribute("data-color", "pink");
toggleColor.innerText = "Pink Theme";
lightThemeRadio.addEventListener("change", () => {
if (lightThemeRadio.checked) {
setTheme("light");
}
});

autoThemeRadio.addEventListener("change", () => {
if (autoThemeRadio.checked) {
updateThemeBasedOnSystemPreference();
}
});

pinkColorButton.addEventListener("click", () => {
setColor("pink");
});

blueColorButton.addEventListener("click", () => {
setColor("blue");
});

0 comments on commit 2751655

Please sign in to comment.