aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Sidebar
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-10 18:17:40 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-11 02:24:44 +0100
commit6315efacd6212a347877102a68f430fffa4ca4ac (patch)
treeb067fb4a1855f881b15e4e11ee161dda778150f9 /src/components/Sidebar
parentcd1078e3a6ddb1b1598723beec4905c123ee85a6 (diff)
refactor(sidebar): use a component to avoid styles repetition
I also fix some overflow/sticky issues. I have to set overflow auto only when there is no button-like links otherwise, with translate, the button is cropped on hover.
Diffstat (limited to 'src/components/Sidebar')
-rw-r--r--src/components/Sidebar/Sidebar.module.scss36
-rw-r--r--src/components/Sidebar/Sidebar.tsx12
2 files changed, 48 insertions, 0 deletions
diff --git a/src/components/Sidebar/Sidebar.module.scss b/src/components/Sidebar/Sidebar.module.scss
new file mode 100644
index 0000000..544a733
--- /dev/null
+++ b/src/components/Sidebar/Sidebar.module.scss
@@ -0,0 +1,36 @@
+@use "@styles/abstracts/mixins" as mix;
+
+.wrapper {
+ grid-column: 2;
+
+ @include mix.media("screen") {
+ @include mix.dimensions("md") {
+ grid-column: 3;
+ grid-row: 2;
+ align-self: stretch;
+ display: flex;
+ flex-flow: column nowrap;
+ position: relative;
+ visibility: hidden;
+
+ &:hover {
+ visibility: visible;
+ }
+
+ > * {
+ visibility: visible;
+ }
+ }
+ }
+}
+
+.body {
+ @include mix.media("screen") {
+ @include mix.dimensions("md") {
+ align-self: flex-start;
+ width: 100%;
+ position: sticky;
+ top: 0;
+ }
+ }
+}
diff --git a/src/components/Sidebar/Sidebar.tsx b/src/components/Sidebar/Sidebar.tsx
new file mode 100644
index 0000000..8c9fa1d
--- /dev/null
+++ b/src/components/Sidebar/Sidebar.tsx
@@ -0,0 +1,12 @@
+import { FunctionComponent } from 'react';
+import styles from './Sidebar.module.scss';
+
+const Sidebar: FunctionComponent = ({ children }) => {
+ return (
+ <aside className={styles.wrapper}>
+ <div className={styles.body}>{children}</div>
+ </aside>
+ );
+};
+
+export default Sidebar;