Use className and forName instead of class and for

This commit is contained in:
Ceda EI 2020-09-09 21:27:00 +05:30
parent 2f185b03e9
commit 21e29c7c7a
1 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* global browser */ /* global browser */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from "react";
function App() { function App() {
const [ advanced, setAdvanced ] = useState(undefined); const [ advanced, setAdvanced ] = useState(undefined);
@ -23,13 +23,13 @@ function App() {
words: [ setWords, ["attendance", "roll number", "present"] ], words: [ setWords, ["attendance", "roll number", "present"] ],
regex: [ setRegex, "" ], regex: [ setRegex, "" ],
flags: [ setFlags, "" ] flags: [ setFlags, "" ]
} };
Object.keys(setterDefaultValue).forEach(key => { Object.keys(setterDefaultValue).forEach(key => {
const [ setter, defaultValue ] = setterDefaultValue[key]; const [ setter, defaultValue ] = setterDefaultValue[key];
browser.storage.local.get(key) browser.storage.local.get(key)
.then(value => { .then(value => {
if (key in value) if (key in value)
setter(value[key]) setter(value[key]);
else { else {
browser.storage.local.set({ [key]: defaultValue }); browser.storage.local.set({ [key]: defaultValue });
@ -76,14 +76,14 @@ function App() {
onChange={e => setAdvanced(e.target.checked)} onChange={e => setAdvanced(e.target.checked)}
checked={advanced} checked={advanced}
/> />
<label for="toggle">Advanced Mode</label> <label forName="toggle">Advanced Mode</label>
<div class="simple" <div className="simple"
style={{ style={{
display: advanced ? "none": "block" display: advanced ? "none": "block"
}} }}
> >
<div <div
class="words" className="words"
style={{ style={{
display: "flex", display: "flex",
flexWrap: "wrap", flexWrap: "wrap",
@ -93,7 +93,7 @@ function App() {
> >
{words.map((word, idx) => {words.map((word, idx) =>
<span <span
class="word" className="word"
key={idx} key={idx}
style={{ style={{
backgroundColor: "#B4FFEF", backgroundColor: "#B4FFEF",
@ -138,14 +138,14 @@ function App() {
id="add-word-button" id="add-word-button"
onClick={e => {setWords([...words, word]); setWord(""); e.preventDefault();}} onClick={e => {setWords([...words, word]); setWord(""); e.preventDefault();}}
type="submit" type="submit"
enabled={word !== ""} disabled={word === ""}
> >
+ +
</button> </button>
</div> </div>
</form> </form>
</div> </div>
<div class="advanced" <div className="advanced"
style={{ style={{
display: advanced ? "flex": "none", display: advanced ? "flex": "none",
alignItems: "baseline", alignItems: "baseline",