Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update styles #4

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/runtime/styles/_editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// this styles for folding headings in markdown editor

@use './mixins' as m;

.yfm {
h1[data-folded],
h2[data-folded],
h3[data-folded],
h4[data-folded],
h5[data-folded],
h6[data-folded] {
@include m.chevron();
}

h1[data-folded] {
@include m.chevron_size_xl();
}

h2[data-folded],
h3[data-folded] {
@include m.chevron_size_l();
}

h4[data-folded] {
@include m.chevron_size_m();
}

h5[data-folded] {
@include m.chevron_size_s();
}

h6[data-folded] {
@include m.chevron_size_xs();
}

h1[data-folded=false],
h2[data-folded=false],
h3[data-folded=false],
h4[data-folded=false],
h5[data-folded=false],
h6[data-folded=false] {
@include m.chevron_open();
}
}
84 changes: 84 additions & 0 deletions src/runtime/styles/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
$chevronIcon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06" clip-rule="evenodd"/></svg>');

@mixin chevron() {
position: relative;

padding-left: 28px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense if these variables were set in the basic diplodoc/transform (.yfm) styles.


&::before {
position: absolute;
z-index: 1;
top: 50%;
left: 0;

content: '';
cursor: pointer;

background-color: currentColor;
mask-image: $chevronIcon;
mask-repeat: no-repeat;
mask-position: center;

transition: transform 0.3s ease;
transform: translateY(-50%) rotate(-90deg);
}
}

@mixin chevron_size_xs() {
&::before {
left: 8px;

width: 20px;
height: 20px;

mask-size: 12px;
}
}

@mixin chevron_size_s() {
&::before {
left: 8px;

width: 20px;
height: 20px;

mask-size: 14px;
}
}

@mixin chevron_size_m() {
&::before {
left: 6px;

width: 20px;
height: 20px;

mask-size: 16px;
}
}

@mixin chevron_size_l() {
&::before {
left: 2px;

width: 24px;
height: 24px;

mask-size: 20px;
}
}

@mixin chevron_size_xl() {
&::before {
width: 28px;
height: 28px;

mask-size: 20px;
}
}

@mixin chevron_open() {
&::before {
transform: translateY(-50%);
}
}
56 changes: 38 additions & 18 deletions src/runtime/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
@use './mixins' as m;
@use './editor';

$paddingLeft: 28px;
$yfmAnchorWidth: 24px;

.heading-section {
$class: &;

&-content {
display: none;
padding-left: $paddingLeft;
overflow: hidden;
transition: height 0.3s ease-in-out;

& > #{$class} {
margin-left: -#{$paddingLeft};
}
}

> h1,
Expand All @@ -14,24 +25,35 @@
> h5,
> h6 {
cursor: pointer;
position: relative;

padding-left: 20px;

&:before {
content: '';
z-index: 1;
left: 0;
top: 50%;
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+CiAgICA8cGF0aCBzdHJva2U9ImN1cnJlbnRDb2xvciIgZmlsbD0ibm9uZSIgZD0iTTMgNmw1IDUgNS01Ii8+Cjwvc3ZnPgo=');
transform: translateY(-50%) rotate(-90deg);
transition: transform 0.3s ease;
height: 20px;
width: 20px;
position: absolute;

@include m.chevron();

.yfm-anchor {
margin-left: -#{$yfmAnchorWidth + $paddingLeft}; // width of yfm-anchor (24px) + padding of heading (28px)
}
}

> h1 {
@include m.chevron_size_xl();
}

> h2,
> h3 {
@include m.chevron_size_l();
}

> h4 {
@include m.chevron_size_m();
}

> h5 {
@include m.chevron_size_s();
}

> h6 {
@include m.chevron_size_xs();
}

&.open {
> #{$class}-content {
display: revert;
Expand All @@ -43,9 +65,7 @@
> h4,
> h5,
> h6 {
&:before {
transform: translateY(-50%);
}
@include m.chevron_open();
}
}
}
Loading