Skip to content

Instantly share code, notes, and snippets.

View ebrugulec's full-sized avatar
💃

Ebru Gulec ebrugulec

💃
  • Berlin, Germany
View GitHub Profile
const generatePassword = () => {
...
setPassword(passwordArray.join(""))
}
useEffect(() => {
document.getElementById("copy_btn").addEventListener("click", copyToClipboard);
return () => {
document.getElementById("copy_btn").removeEventListener("click", copyToClipboard);
}
}, [])
useEffect(() => {
generatePassword()
checkPasswordStrength()
function PasswordGenerator(props){
const [password, setPassword] = useState('')
const [length, setLength] = useState(props.length)
const [digitCount, setDigitCount] = useState(props.digitCount)
const [symbolCount, setSymbolCount] = useState(props.symbolCount)
const [copy, setCopy] = useState(false)
const [strengthScore, setStrengthScore] = useState(0)
const [strengthText, setStrengthText] = useState('')
const [settings, setSettings] = useState({
maxLength: props.maxLength,
<input
id="length"
type="range"
min="6"
className="range-slider"
max={maxLength}
value={length}
onChange={(e) => this.handleOnChange(e, 'length')}
/>
checkPasswordStrength = () => {
...
this.setState({
strengthScore: 10,
strengthText: 'weak'
})
}
copyToClipboard = () => {
...
this.setState({
generatePassword = () => {
...
this.setState({
password: passwordArray.join("")
}, () => {
this.checkPasswordStrength();
})
}
componentDidMount(){
this.generatePassword()
this.checkPasswordStrength()
document.getElementById("copy_btn").addEventListener("click", this.copyToClipboard);
}
componentWillUnmount(){
document.getElementById("copy_btn").removeEventListener("click", this.copyToClipboard);
}
class PasswordGenerator extends Component {
constructor(props){
super(props)
this.state = {
password: '',
length: 12,
digits: 4,
symbols: 2,
copy: false,
strengthScore: 0,
# .gitignore
node_modules
dist
module.exports = {
output: {
path: path.join(__dirname, "examples/dist"),
filename: "bundle.js"
},
}