-
Notifications
You must be signed in to change notification settings - Fork 68
Добавляет кастомный виджет со звёздочками GitHub #1316
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
ac3f8e2
fef0d18
ad346bd
c6e3917
a378497
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> |
| 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() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| .github-widget { | ||
| --widget-padding: .4em .4em .25em; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Дак вот я выравнил специально так) Потому что если сделать по центру, то визуально надпись оказывается не по центру. Заглавная буква и иконка выше цифры получаются. Сейчас как будто ровно, разве нет? Попробуй в девтулзе сделать одинаковые паддинги.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Смотрю на ноуте 1920*1080 с 125% размером текста. Это по-моему распространённая настройка
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ты знаешь, иконка действительно пляшет, если менять масштаб. У меня есть идея как это исправить. Но сперва я бы предложил узнать мнение Светы @skorobaeus, а вообще этот MVP-дизайн ей нравится? Стоит ли им заниматься дальше или лучше применить другой UI в целом. |
||
| --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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Про иконку если запрос упал интересная идея. Правда я видел у нас ещё сервайс воркер, мб через него можно придумать решение. То есть будет брать из кеша, если есть, а если и там нет, то тогда иконку с какой-нибудь надписью, вроде "Наш репозиторий". Только какой тогда смысл давать ссылку на репозиторий для автономщиков, если они ее не смогут открыть?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Думаю это баг рендера браузера, или какая-то история с пиксельным отображением именно на стороне экрана. Потому что по идее там нету того, чем обрезаться, т.к. пустое пространство между иконкой и текстом. Такое бывает.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| 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)); | ||
| } | ||








Uh oh!
There was an error while loading. Please reload this page.