Skip to content

Instantly share code, notes, and snippets.

View fredbegin11's full-sized avatar

Frédéric Bégin fredbegin11

  • Québec Cité
View GitHub Profile
@fredbegin11
fredbegin11 / Markup-1
Created October 19, 2020 11:18
Markup-1
<div class="container">
<span>Label #1</span>
<span>Label #2</span>
<span>Label #3</span>
</div>
.card {
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2), 0 4px 20px 0 rgba(0, 0, 0, 0.19);
display: flex;
flex-direction: column;
max-width: 300px;
&__title {
font-size: 24px;
padding: 10px;
}
import React from 'react';
import PropTypes from 'prop-types';
const Card = ({ description, isWarning, title }) => (
<article className={`card ${isWarning && '--warning'}`}>
<h3 className="card__title">{title}</h3>
<p className="card__description">{description}</p>
</article>
);
.header {
&__title {
font-size: 2rem;
@include phone {
font-size: 1rem;
}
}
}
@mixin small-phone {
@media (max-width: 375px) {
@content;
}
}
@mixin phone {
@media (max-width: 767px) {
@content;
}
.header {
&__title {
font-size: 24px;
}
&__subtitle {
font-size: 20px;
&.--warning {
color: yellow;
$primary-color: #ffffff
body {
background-color: $primary-color;
}
import axios from 'axios';
import React, { useState, useEffect } from 'react';
const Rhyme = () => {
const [word, setWord] = useState('');
const [rhymes, setRhymes] = useState([]);
const fetchRhyme = async () => {
const response = await axios.get(`https://api.datamuse.com/words?rel_rhy=${word}`);
setRhymes(response.data);
import React, { useState } from 'react';
const MultiCounter = () => {
const [age, setAge] = useState(26);
const [months, setMonths] = useState(1);
return (
<>
<p>Age: {age}</p>
<button onClick={() => setAge(age + 1)}>Increment Age</button>
@fredbegin11
fredbegin11 / SimpleCounterWithStateHook.js
Created February 9, 2019 03:23
Simple Counter using State Hook
import React, { useState } from 'react';
const Counter = () => {
const [count, setCount] = useState(0);
return (
<>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
<button onClick={() => setCount(count - 1)}>Decrement</button>