Ocelot-Social/webapp/scss.html
2025-07-18 13:37:17 +00:00

55 lines
28 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en-US" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="generator" content="VuePress 2.0.0-rc.18" />
<meta name="theme" content="VuePress Theme Hope 2.0.0-rc.59" />
<style>
:root {
--vp-c-bg: #fff;
}
[data-theme="dark"] {
--vp-c-bg: #1b1b1f;
}
html,
body {
background: var(--vp-c-bg);
}
</style>
<script>
const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
const systemDarkMode =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;
if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
document.documentElement.setAttribute("data-theme", "dark");
}
</script>
<meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>SCSS - Code Guidelines | Ocelot.Social Documentation</title><meta name="description" content="Ocelot.Social Documentation">
<link rel="preload" href="/assets/style-D4x0XHGi.css" as="style"><link rel="stylesheet" href="/assets/style-D4x0XHGi.css">
<link rel="modulepreload" href="/assets/app-42vVvAb-.js"><link rel="modulepreload" href="/assets/scss.html-Cg6fmwql.js"><link rel="modulepreload" href="/assets/plugin-vue_export-helper-DlAUqK2U.js">
<link rel="prefetch" href="/assets/CHANGELOG.html-BysofDL5.js" as="script"><link rel="prefetch" href="/assets/CODE_OF_CONDUCT.html-XkY1NwpG.js" as="script"><link rel="prefetch" href="/assets/CONTRIBUTING.html-C06pWh3B.js" as="script"><link rel="prefetch" href="/assets/LICENSE.html-DEdfeOfu.js" as="script"><link rel="prefetch" href="/assets/index.html-CtTXU5Um.js" as="script"><link rel="prefetch" href="/assets/SUMMARY.html-eMHIsrjp.js" as="script"><link rel="prefetch" href="/assets/documentation.html-OXRtZK5T.js" as="script"><link rel="prefetch" href="/assets/testing.html-BLGom9kX.js" as="script"><link rel="prefetch" href="/assets/index.html-DBDIpVfz.js" as="script"><link rel="prefetch" href="/assets/graphql.html-CD9OLTd0.js" as="script"><link rel="prefetch" href="/assets/neo4j-graphql-js.html-C1jNzrZg.js" as="script"><link rel="prefetch" href="/assets/testing.html-9R_o7GUA.js" as="script"><link rel="prefetch" href="/assets/index.html-BctnqxTU.js" as="script"><link rel="prefetch" href="/assets/features.html-9sdgMtvT.js" as="script"><link rel="prefetch" href="/assets/TODO-next-update.html-B47grlPD.js" as="script"><link rel="prefetch" href="/assets/deployment-values.html-DnbV66LJ.js" as="script"><link rel="prefetch" href="/assets/index.html-uDvjmpCh.js" as="script"><link rel="prefetch" href="/assets/index.html-s7wtk0sZ.js" as="script"><link rel="prefetch" href="/assets/index.html-Dyiaj34I.js" as="script"><link rel="prefetch" href="/assets/components.html-nG54ZAfH.js" as="script"><link rel="prefetch" href="/assets/html.html-BWIJnzB9.js" as="script"><link rel="prefetch" href="/assets/testing.html-CymAGKPg.js" as="script"><link rel="prefetch" href="/assets/vue.html-BZ4GqO8V.js" as="script"><link rel="prefetch" href="/assets/index.html-CRWlgeUj.js" as="script"><link rel="prefetch" href="/assets/GraphQL-Playground.html-C5_18a4M.js" as="script"><link rel="prefetch" href="/assets/index.html-CwWgTIoq.js" as="script"><link rel="prefetch" href="/assets/index.html-AbInmNTj.js" as="script"><link rel="prefetch" href="/assets/demo.html-BVi66rFc.js" as="script"><link rel="prefetch" href="/assets/index.html-BNvPlqKz.js" as="script"><link rel="prefetch" href="/assets/404.html-DjkuAEQW.js" as="script"><link rel="prefetch" href="/assets/index.html-BMDvNWkW.js" as="script"><link rel="prefetch" href="/assets/index.html-BJ9euNS6.js" as="script"><link rel="prefetch" href="/assets/index.html-CUaB9O4R.js" as="script"><link rel="prefetch" href="/assets/index.html-BGmQtDin.js" as="script"><link rel="prefetch" href="/assets/index.html-BvkTjNKI.js" as="script"><link rel="prefetch" href="/assets/index.html-wHI91PGm.js" as="script"><link rel="prefetch" href="/assets/index.html-Su4wUczQ.js" as="script"><link rel="prefetch" href="/assets/index.html-2aSnFNii.js" as="script"><link rel="prefetch" href="/assets/photoswipe.esm-GXRgw7eJ.js" as="script"><link rel="prefetch" href="/assets/SearchResult-DOliiBY1.js" as="script"><link rel="prefetch" href="/assets/setupDevtools-7MC2TMWH-CCl1VMYd.js" as="script">
</head>
<body>
<div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content" class="vp-skip-link sr-only">Skip to main content</a><!--]--><!--[--><div class="theme-container external-link-icon pure has-toc" vp-container><!--[--><header id="navbar" class="vp-navbar" vp-navbar><div class="vp-navbar-start"><button type="button" class="vp-toggle-sidebar-button" title="Toggle Sidebar"><span class="icon"></span></button><!----><!--[--><a class="route-link vp-brand" href="/" aria-label="Take me home"><img class="vp-nav-logo" src="/logo.svg" alt><!----><span class="vp-site-name hide-in-pad">Ocelot.Social Documentation</span></a><!--]--><!----></div><div class="vp-navbar-center"><!----><!--[--><nav class="vp-nav-links"><div class="vp-nav-item hide-in-mobile"><a class="auto-link external-link" href="https://stage.ocelot.social/" aria-label="Demo" target="_self"><!---->Demo<!----></a></div></nav><!--]--><!----></div><div class="vp-navbar-end"><!----><!--[--><div class="vp-nav-item vp-action"><a class="vp-action-link" href="https://github.com/Ocelot-Social-Community/Ocelot-Social" target="_blank" rel="noopener noreferrer" aria-label="GitHub"><svg xmlns="http://www.w3.org/2000/svg" class="icon github-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="github icon" name="github" style="width:1.25rem;height:1.25rem;vertical-align:middle;"><path d="M511.957 21.333C241.024 21.333 21.333 240.981 21.333 512c0 216.832 140.544 400.725 335.574 465.664 24.49 4.395 32.256-10.07 32.256-23.083 0-11.69.256-44.245 0-85.205-136.448 29.61-164.736-64.64-164.736-64.64-22.315-56.704-54.4-71.765-54.4-71.765-44.587-30.464 3.285-29.824 3.285-29.824 49.195 3.413 75.179 50.517 75.179 50.517 43.776 75.008 114.816 53.333 142.762 40.79 4.523-31.66 17.152-53.377 31.19-65.537-108.971-12.458-223.488-54.485-223.488-242.602 0-53.547 19.114-97.323 50.517-131.67-5.035-12.33-21.93-62.293 4.779-129.834 0 0 41.258-13.184 134.912 50.346a469.803 469.803 0 0 1 122.88-16.554c41.642.213 83.626 5.632 122.88 16.554 93.653-63.488 134.784-50.346 134.784-50.346 26.752 67.541 9.898 117.504 4.864 129.834 31.402 34.347 50.474 78.123 50.474 131.67 0 188.586-114.73 230.016-224.042 242.09 17.578 15.232 33.578 44.672 33.578 90.454v135.85c0 13.142 7.936 27.606 32.854 22.87C862.25 912.597 1002.667 728.747 1002.667 512c0-271.019-219.648-490.667-490.71-490.667z"></path></svg></a></div><div class="vp-nav-item hide-in-mobile"><button type="button" class="vp-color-mode-switch" id="color-mode-switch"><svg xmlns="http://www.w3.org/2000/svg" class="icon auto-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="auto icon" name="auto" style="display:block;"><path d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="dark icon" name="dark" style="display:none;"><path d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="light icon" name="light" style="display:none;"><path d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z"></path></svg></button></div><!--[--><button type="button" class="search-pro-button" aria-label="Search"><svg xmlns="http://www.w3.org/2000/svg" class="icon search-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="search icon" name="search"><path d="M192 480a256 256 0 1 1 512 0 256 256 0 0 1-512 0m631.776 362.496-143.2-143.168A318.464 318.464 0 0 0 768 480c0-176.736-143.264-320-320-320S128 303.264 128 480s143.264 320 320 320a318.016 318.016 0 0 0 184.16-58.592l146.336 146.368c12.512 12.48 32.768 12.48 45.28 0 12.48-12.512 12.48-32.768 0-45.28"></path></svg><div class="search-pro-placeholder">Search</div><div class="search-pro-key-hints"><kbd class="search-pro-key">Ctrl</kbd><kbd class="search-pro-key">K</kbd></div></button><!--]--><!--]--><!----><button type="button" class="vp-toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false" aria-controls="nav-screen"><span><span class="vp-top"></span><span class="vp-middle"></span><span class="vp-bottom"></span></span></button></div></header><!----><!--]--><!----><div class="toggle-sidebar-wrapper"><span class="arrow start"></span></div><aside id="sidebar" class="vp-sidebar" vp-sidebar><!----><ul class="vp-sidebar-links"><li><a class="route-link auto-link vp-sidebar-link" href="/" aria-label="Introduction"><!---->Introduction<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/neo4j/" aria-label="Neo4J"><!---->Neo4J<!----></a></li><li><section class="vp-sidebar-group"><p class="vp-sidebar-header clickable"><!----><a class="route-link auto-link vp-sidebar-title no-external-link-icon" href="/backend/" aria-label="Backend"><!---->Backend<!----></a><!----></p><ul class="vp-sidebar-links"><li><a class="route-link auto-link vp-sidebar-link" href="/backend/graphql.html" aria-label="GraphQL"><!---->GraphQL<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/backend/neo4j-graphql-js.html" aria-label="neo4j-graphql-js"><!---->neo4j-graphql-js<!----></a></li></ul></section></li><li><section class="vp-sidebar-group"><p class="vp-sidebar-header clickable active"><!----><a class="route-link route-link-active auto-link vp-sidebar-title no-external-link-icon" href="/webapp/" aria-label="Webapp (Frontend)"><!---->Webapp (Frontend)<!----></a><!----></p><ul class="vp-sidebar-links"><li><a class="route-link auto-link vp-sidebar-link" href="/webapp/components.html" aria-label="Components"><!---->Components<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/webapp/html.html" aria-label="HTML"><!---->HTML<!----></a></li><li><a class="route-link route-link-active auto-link vp-sidebar-link active" href="/webapp/scss.html" aria-label="SCSS"><!---->SCSS<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/webapp/vue.html" aria-label="Vue"><!---->Vue<!----></a></li></ul></section></li><li><section class="vp-sidebar-group"><p class="vp-sidebar-header clickable"><!----><a class="route-link auto-link vp-sidebar-title no-external-link-icon" href="/testing.html" aria-label="Testing Guide"><!---->Testing Guide<!----></a><!----></p><ul class="vp-sidebar-links"><li><a class="route-link auto-link vp-sidebar-link" href="/cypress/" aria-label="End-to-end Tests"><!---->End-to-end Tests<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/webapp/testing.html" aria-label="Webapp (Frontend) Tests"><!---->Webapp (Frontend) Tests<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/backend/testing.html" aria-label="Backend Tests"><!---->Backend Tests<!----></a></li></ul></section></li><li><a class="route-link auto-link vp-sidebar-link" href="/deployment/" aria-label="Deployment"><!---->Deployment<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/CONTRIBUTING.html" aria-label="Contributing"><!---->Contributing<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/cypress/features.html" aria-label="Feature Specification"><!---->Feature Specification<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/CODE_OF_CONDUCT.html" aria-label="Code of Conduct"><!---->Code of Conduct<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/documentation.html" aria-label="Documentation"><!---->Documentation<!----></a></li><li><a class="route-link auto-link vp-sidebar-link" href="/LICENSE.html" aria-label="License"><!---->License<!----></a></li></ul><!----></aside><!--[--><!--[--><main id="main-content" class="vp-page"><!--[--><!----><!----><nav class="vp-breadcrumb disable"></nav><div class="vp-page-title"><h1><!---->SCSS - Code Guidelines</h1><div class="page-info"><!----><!----><span class="page-date-info" aria-label="Writing Date"><svg xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="calendar icon" name="calendar"><path d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z"></path></svg><span data-allow-mismatch="text">July 17, 2025</span><meta property="datePublished" content="2025-07-17T11:15:35.000Z"></span><!----><span class="page-reading-time-info" aria-label="Reading Time"><svg xmlns="http://www.w3.org/2000/svg" class="icon timer-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="timer icon" name="timer"><path d="M799.387 122.15c4.402-2.978 7.38-7.897 7.38-13.463v-1.165c0-8.933-7.38-16.312-16.312-16.312H256.33c-8.933 0-16.311 7.38-16.311 16.312v1.165c0 5.825 2.977 10.874 7.637 13.592 4.143 194.44 97.22 354.963 220.201 392.763-122.204 37.542-214.893 196.511-220.2 389.397-4.661 5.049-7.638 11.651-7.638 19.03v5.825h566.49v-5.825c0-7.379-2.849-13.981-7.509-18.9-5.049-193.016-97.867-351.985-220.2-389.527 123.24-37.67 216.446-198.453 220.588-392.892zM531.16 450.445v352.632c117.674 1.553 211.787 40.778 211.787 88.676H304.097c0-48.286 95.149-87.382 213.728-88.676V450.445c-93.077-3.107-167.901-81.297-167.901-177.093 0-8.803 6.99-15.793 15.793-15.793 8.803 0 15.794 6.99 15.794 15.793 0 80.261 63.69 145.635 142.01 145.635s142.011-65.374 142.011-145.635c0-8.803 6.99-15.793 15.794-15.793s15.793 6.99 15.793 15.793c0 95.019-73.789 172.82-165.96 177.093z"></path></svg><span>About 2 min</span><meta property="timeRequired" content="PT2M"></span><!----><!----></div><hr></div><div class="vp-toc-placeholder"><aside id="toc" vp-toc><!----><div class="vp-toc-header">On This Page<!----><div class="arrow end"></div></div><div class="vp-toc-wrapper"><ul class="vp-toc-list"><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#we-use-classes-over-tags-and-ids">We use classes over tags and ids</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#we-use-design-tokens-instead-of-magic-numbers">We use design tokens instead of magic numbers</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#we-name-our-classes-after-components">We name our classes after components</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#we-use-variants-instead-of-overriding-styles">We use variants instead of overriding styles</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#we-style-within-the-component-we-position-when-we-use-it">We style within the component, we position when we use it</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#recommended-reads">Recommended reads</a></li><!----><!--]--></ul><div class="vp-toc-marker" style="top:-1.7rem;"></div></div><!----></aside></div><!----><div class="theme-hope-content" vp-content><h1 id="scss-code-guidelines" tabindex="-1"><a class="header-anchor" href="#scss-code-guidelines"><span>SCSS - Code Guidelines</span></a></h1><h2 id="we-use-classes-over-tags-and-ids" tabindex="-1"><a class="header-anchor" href="#we-use-classes-over-tags-and-ids"><span>We use classes over tags and ids</span></a></h2><p>Never apply styles to <code>tags</code> or <code>ids</code> use <code>classes</code> instead!</p><p>Why?</p><ul><li>HTML tags are responsible for the document <em>structure</em>, not the looks</li><li>targeting HTML tags comes with performance issues</li><li>ids are responsible for identifying a unique element, not for styling it</li><li>ids have higher specificity than classes and therefore don&#39;t play well together</li><li>classes can be combined and reused while ids are unique</li></ul><p>For more background see the following articles on <a href="https://frontstuff.io/you-need-to-stop-targeting-tags-in-css" target="_blank" rel="noopener noreferrer">why not to style tags</a> and <a href="https://dev.to/clairecodes/reasons-not-to-use-ids-in-css-4ni4" target="_blank" rel="noopener noreferrer">why not to style ids</a>.</p><h2 id="we-use-design-tokens-instead-of-magic-numbers" tabindex="-1"><a class="header-anchor" href="#we-use-design-tokens-instead-of-magic-numbers"><span>We use design tokens instead of magic numbers</span></a></h2><p>In order to achieve a consistent look and feel we use a set of pre-defined <code>design tokens</code> to style our components, for example <code>colors</code>, <code>sizes</code> and <code>box-shadows</code>. These tokens are stored as <code>SCSS variables</code> and reused throughout the app.</p><p>So, instead of typing <em>pixel values</em> or <em>hex codes</em> make sure you use design tokens such as <code>height-header</code> or <code>color-input-border</code>.</p><h2 id="we-name-our-classes-after-components" tabindex="-1"><a class="header-anchor" href="#we-name-our-classes-after-components"><span>We name our classes after components</span></a></h2><p>Our SCSS styles live within the corresponding component (see the <a href="https://vuejs.org/v2/guide/single-file-components.html" target="_blank" rel="noopener noreferrer">Vue.js docs for single-file components</a> for reference) and should therefore carry the same <em>unique</em> name.</p><p>Why?</p><ul><li>it clearly ties the styles to the one component</li><li>having unique class names means styles will not be accidentally overwritten in other files</li><li>we can avoid using <code>scoped CSS</code> which <a href="https://vue-loader.vuejs.org/guide/scoped-css.html#also-keep-in-mind" target="_blank" rel="noopener noreferrer">comes with performance caveats</a></li></ul><h2 id="we-use-variants-instead-of-overriding-styles" tabindex="-1"><a class="header-anchor" href="#we-use-variants-instead-of-overriding-styles"><span>We use variants instead of overriding styles</span></a></h2><p>Components will sometimes need to look different depending on the context in which they are used a button might for example be <code>green</code> when it represents a call to action and <code>red</code> when it triggers a destructive action. Rather than making the <code>rounded-button</code> component <code>green</code> by default and then overriding the <code>color</code> for, say, the <code>delete-account</code> action use variants! Pass the <code>rounded-button</code> a prop, such as <code>color: danger</code>, and then apply the respective <code>variant class</code>.</p><p>Name variant classes with a dash prefix, such as <code>-danger</code>, then target them like this:</p><div class="language-scss line-numbers-mode" data-highlighter="shiki" data-ext="scss" data-title="scss" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34;"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code><span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66;">.rounded-button</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> {</span></span>
<span class="line"><span style="--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic;"> /* other css styles */</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75;"> &amp;</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66;">.-danger</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> {</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> color: </span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75;">$color-danger</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;">;</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> }</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="we-style-within-the-component-we-position-when-we-use-it" tabindex="-1"><a class="header-anchor" href="#we-style-within-the-component-we-position-when-we-use-it"><span>We <em>style</em> within the component, we <em>position</em> when we use it</span></a></h2><p>In order to make components truly reusable it is important to limit their styles to, well, their actual <em>styling</em>. What color are they, how big is the text, what happens on <code>hover</code>, do they have a rounded border all that is part of it.</p><p>Margins, alignment and positioning on the other hand need to be defined in the <em>parent</em> because the same component might sometimes be aligned to the left, sometimes to the right and sometimes float above other content. For more details see the <a href="https://rscss.io/layouts.html" target="_blank" rel="noopener noreferrer">rscss guidelines</a>.</p><p>To do that, use the <code>child selector</code>, like this:</p><div class="language-scss line-numbers-mode" data-highlighter="shiki" data-ext="scss" data-title="scss" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34;"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code><span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66;">.login-form</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> {</span></span>
<span class="line"><span style="--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic;"> /* other css styles */</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> &gt; </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66;">.rounded-button</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> {</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> margin: </span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75;">$margin-small</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;">;</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> justify-self: </span><span style="--shiki-light:#383A42;--shiki-dark:#D19A66;">flex-end</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;">;</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;"> }</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>A special case are dimensions like <code>width</code> and <code>height</code>. If it is important that a component always has the same dimensions (the height of a button should be consistent, for example) define it <em>within the component</em> itself, if a component should have flexible dimensions (a card, for example, could stretch over the whole screen in one place and be limited to a certain width in another) define the dimensions <em>in the parent</em>.</p><h2 id="recommended-reads" tabindex="-1"><a class="header-anchor" href="#recommended-reads"><span>Recommended reads</span></a></h2><p>For a deeper dive into the WHY and HOW have a look at the following resources which the above guidelines are based on:</p><ul><li><a href="https://rscss.io/index.html" target="_blank" rel="noopener noreferrer">rscss reasonable system for css stylesheet structure</a></li><li><a href="https://csswizardry.net/talks/2014/11/itcss-dafed.pdf" target="_blank" rel="noopener noreferrer">itcss inverted triangle architecture for css</a></li></ul></div><!----><footer class="vp-page-meta"><div class="vp-meta-item edit-link"><a class="auto-link external-link vp-meta-label" href="https://github.com/Ocelot-Social-Community/Ocelot-Social/edit/master/./webapp/scss.md" aria-label="Edit this page" rel="noopener noreferrer" target="_blank"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon edit-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="edit icon" name="edit"><path d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"></path><path d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"></path></svg><!--]-->Edit this page<!----></a></div><div class="vp-meta-item git-info"><!----><!----></div></footer><nav class="vp-page-nav"><a class="route-link auto-link prev" href="/webapp/html.html" aria-label="HTML"><div class="hint"><span class="arrow start"></span>Prev</div><div class="link"><!---->HTML</div></a><a class="route-link auto-link next" href="/webapp/vue.html" aria-label="Vue"><div class="hint">Next<span class="arrow end"></span></div><div class="link">Vue<!----></div></a></nav><!----><!----><!--]--></main><!--]--><!--]--><footer class="vp-footer-wrapper" vp-footer><div class="vp-footer">Released under the <a class="vt-link link link" href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer"><!--[-->MIT License<!--]--><!----></a>.</div><div class="vp-copyright">&copy; by <a href="https://busfaktor.org" target="_blank">busFaktor() e.V.</a> & Authors | <a href="https://ocelot.social/en/impressum/">Imprint</a></div></footer></div><!--]--><!--]--><!--[--><!----><!----><!--[--><!--]--><!--]--><!--]--></div>
<script type="module" src="/assets/app-42vVvAb-.js" defer></script>
</body>
</html>