-
Notifications
You must be signed in to change notification settings - Fork 65
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
Добавляет кастомный виджет со звёздочками GitHub #1316
Draft
Inventoris
wants to merge
1
commit into
doka-guide:main
Choose a base branch
from
Inventoris:feature/github-widget
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ | ||
<div class="github-widget"> | ||
<a class="github-widget__repository" href="https://github.com/doka-guide/content" aria-label="Открыть репозиторий контента Доки на GitHub"> | ||
<svg width="14" height="14" viewBox="0 0 24 24" aria-hidden="true" class="github-widget__star"> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M10.1507 2.3649C10.8306 0.713558 13.1694 0.713567 13.8494 2.3649L16.1856 8.0386L21.4255 8.34683C23.2632 8.45493 | ||
23.9912 10.7786 22.5437 11.916L18.1816 15.3433L19.9202 20.2694C20.5648 22.0955 18.497 23.6802 16.9012 22.5831L12 | ||
19.2135L7.09881 22.5831C5.50303 23.6802 3.43525 22.0955 4.07977 20.2694L5.81838 15.3433L1.45635 11.916C0.0087955 10.7787 | ||
0.736801 8.45493 2.57454 8.34683L7.81442 8.0386L10.1507 2.3649ZM12 3.1264L9.18559 9.9614L2.69199 10.3434L8.18164 | ||
14.6567L5.96575 20.935L12 16.7865L18.0343 20.935L15.8184 14.6567L21.308 10.3434L14.8144 9.9614L12 3.1264Z" | ||
/> | ||
</svg> | ||
Звёзд | ||
</a> | ||
<a class="github-widget__stargazers" href="https://github.com/doka-guide/content/stargazers" aria-label="Посмотреть список людей, которые поставили звёздочку репозиторию контента">O_o</a> | ||
</div> |
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,16 @@ | ||
async function init() { | ||
const stargazers = document.querySelector('.github-widget__stargazers') | ||
|
||
if (!stargazers) return | ||
|
||
try { | ||
const response = await fetch('https://api.github.com/repos/doka-guide/content') | ||
const { stargazers_count: stargazersCount } = await response.json() | ||
|
||
stargazers.textContent = `${(stargazersCount / 1000).toFixed(1).replace(/\.0$/, '')}к` | ||
} catch (error) { | ||
console.error('Ошибка формирования количества звёзд репозитория контента', error) | ||
} | ||
} | ||
|
||
init() |
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,62 @@ | ||
.github-widget { | ||
--widget-padding: .4em .4em .25em; | ||
--bg-lightness: calc(var(--is-light-theme-on)* 87% + var(--is-dark-theme-on)* 20%); | ||
--bg-hover-lightness: calc(var(--is-light-theme-on)* 95% + var(--is-dark-theme-on)* 12%); | ||
display: flex; | ||
} | ||
|
||
.github-widget__repository, | ||
.github-widget__stargazers { | ||
font-size: calc(var(--font-size-s) * 0.98); | ||
line-height: 1; | ||
color: hsl(var(--color-base-text)); | ||
text-decoration: none; | ||
padding: var(--widget-padding); | ||
border: 1px solid hsl(var(--color-fade)); | ||
transition: background-color .2s; | ||
} | ||
|
||
@media (width >= 768px) { | ||
.github-widget__repository, | ||
.github-widget__stargazers { | ||
font-size: var(--font-size-s); | ||
} | ||
} | ||
|
||
.github-widget__repository { | ||
display: flex; | ||
gap: 5px; | ||
border-radius: 2em 0 0 2em; | ||
background-color: hsl(0 0% var(--bg-lightness)); | ||
} | ||
|
||
.github-widget__star { | ||
fill: hsl(var(--color-base-text)); | ||
} | ||
|
||
@media (width >= 768px) { | ||
.github-widget__star { | ||
width: 15px; | ||
height: 15px; | ||
margin-top: -.1em; | ||
} | ||
} | ||
|
||
.github-widget__stargazers { | ||
border-radius: 0 2em 2em 0; | ||
border-left: none; | ||
} | ||
|
||
.github-widget__repository:focus-within, | ||
.github-widget__stargazers:focus-within { | ||
outline: auto 2px -webkit-focus-ring-color; | ||
} | ||
|
||
.github-widget:hover .github-widget__repository { | ||
background-color: transparent; | ||
} | ||
|
||
.github-widget:hover .github-widget__repository:hover, | ||
.github-widget__stargazers:hover { | ||
background-color: hsl(0 0% var(--bg-hover-lightness)); | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет,
смотрится как отличная замена текущему виджету!
У меня тут пару сомненений:
k
только после проверки числа ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет, супер)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Запрос упал, но в консоли сообщение: "Ошибка формирования количества звёзд репозитория контента".
Скорее уж в этом случае это ошибка получения данных о репозитории
Впрочем, может это не важно )