-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавляет превью цвета в блоках кода (#996)
* Добавляет код * Правит выравнивание
- Loading branch information
1 parent
137e5f9
commit 6706aa3
Showing
6 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.token.color::before { | ||
content: ""; | ||
display: inline-block; | ||
width: 10px; | ||
height: 10px; | ||
margin: var(--color-picker-margin); | ||
background-color: var(--color-picker); | ||
line-height: 0; | ||
} | ||
|
||
.color-picker__internal { | ||
--color-picker-margin: 0 2px; | ||
} | ||
|
||
.color-picker__external { | ||
--color-picker-margin: 0 2px 0 0; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @param {Window} window | ||
*/ | ||
module.exports = function (window) { | ||
const content = window.document.querySelector('.article__content-inner') | ||
const color = content?.querySelectorAll('.token.color') | ||
|
||
color?.forEach(function (item) { | ||
item.style.setProperty('--color-picker', ` ${item.textContent}`) | ||
|
||
if (/[(]/.test(item.previousElementSibling.textContent)) { | ||
item.classList.add('color-picker__internal') // Добавляет дополнительный margin слева, если токен цвета внутри скобок | ||
} else { | ||
item.classList.add('color-picker__external') | ||
} | ||
}) | ||
} |