Created
December 27, 2021 10:00
-
-
Save Uvacoder/9541f3753d8979c8181263bb62fc2dc4 to your computer and use it in GitHub Desktop.
[Emoji Added] - A beginner's guide to applying color to UI design
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="card"> | |
<div class="card__img-wrapper"> | |
<div class="card__img" role="img">🌿</div> | |
</div> | |
<div class="card__content-wrapper"> | |
<p class="card__meta">Cooking</p> | |
<div class="card__header"> | |
<h1 class="card__title">Fresh herbs</h1> | |
<svg class="card__heart" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> | |
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path> | |
</svg> | |
</div> | |
<p class="card__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Est tempora facere voluptatum suscipit mollitia nulla unde aliquid animi molestias laboriosam?</p> | |
<div class="card__footer"> | |
<button class="card__btn card__btn--outline">Add to cart</button> | |
<button class="card__btn">Buy now</button> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const productImage = document.querySelector(".card__img"); | |
// replace the emoji with an svg version that will scale to larger sizes | |
twemoji.parse(productImage, { | |
folder: "svg", | |
ext: ".svg", | |
callback: function (icon, options, variant) { | |
productImage.style.display = "block"; | |
return "".concat(options.base, options.size, "/", icon, options.ext); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
:root { | |
--black: hsl(0, 0%, 0%); | |
--white: hsl(0, 0%, 100%); | |
} | |
html { | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} | |
body { | |
min-height: 100vh; | |
display: grid; | |
place-items: center; | |
padding: 2rem; | |
font-family: "Inter", system-ui, sans-serif; | |
line-height: 1; | |
} | |
.card { | |
max-width: 26rem; | |
min-width: 16rem; | |
background: var(--white); | |
color: var(--black); | |
border-radius: 1rem; | |
overflow: hidden; | |
box-shadow: 0px 2px 4px 0px rgb(0 0 0 / 8%); | |
} | |
.card__img-wrapper { | |
display: grid; | |
place-items: center; | |
margin-bottom: 2rem; | |
padding: 2rem; | |
} | |
.card__content-wrapper { | |
padding: 0 2rem 2rem; | |
} | |
.card__img { | |
width: 50%; | |
max-width: 6rem; | |
/* card image is shown once twemoji has parsed */ | |
display: none; | |
} | |
.card__meta { | |
position: relative; | |
display: inline-block; | |
margin-bottom: 0.75rem; | |
padding-right: 0.75rem; | |
font-size: 0.75rem; | |
line-height: 0.75rem; | |
} | |
.card__meta:before { | |
position: absolute; | |
top: 50%; | |
right: 0; | |
transform: translateY(-50%); | |
content: ""; | |
width: 0.25rem; | |
height: 0.25rem; | |
background: var(--black); | |
border-radius: 50%; | |
} | |
.card__header { | |
display: flex; | |
margin-bottom: 1.75rem; | |
} | |
.card__title { | |
font-size: 1.5rem; | |
line-height: 1.5rem; | |
font-weight: 600; | |
letter-spacing: -0.025em; | |
} | |
.card__heart { | |
width: 1rem; | |
height: 1rem; | |
margin-top: 0.25rem; | |
margin-left: auto; | |
} | |
.card__description { | |
margin-bottom: 2.25rem; | |
font-size: 0.875rem; | |
line-height: 1.5rem; | |
hyphens: auto; | |
-webkit-hyphens: auto; | |
} | |
.card__footer { | |
display: grid; | |
grid-template-columns: 1fr 1fr; | |
grid-gap: 1rem; | |
} | |
.card__btn { | |
width: 100%; | |
height: 2.5rem; | |
font-size: 0.875rem; | |
font-family: inherit; | |
font-weight: 500; | |
background: var(--black); | |
color: var(--white); | |
border: none; | |
border-radius: 0.5rem; | |
cursor: pointer; | |
} | |
.card__btn--outline { | |
background: var(--white); | |
color: var(--black); | |
border: 1px solid var(--black); | |
} | |
@media only screen and (max-width: 480px) { | |
body { | |
padding: 1rem; | |
} | |
.card__content-wrapper { | |
padding: 0 1.5rem 1.5rem; | |
} | |
.card__footer { | |
grid-gap: 0.75rem; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment