Skip to content
Open
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
4 changes: 2 additions & 2 deletions public/locales/en/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"readme": "Readme",
"changelog": "Changelog",
"about": "About library",
"stars": "Stars",
"stars": "Support library with a star",
"version": "Version",
"lastUpdate": "Last update",
"repository": "Repository",
"license": "License",
"issues": "Issues",
"maintainers": "Maintainers",
"contributors": "Contributors"
}
}
4 changes: 2 additions & 2 deletions public/locales/es/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"readme": "Léeme",
"changelog": "Registro de cambios",
"about": "Acerca de la biblioteca",
"stars": "Estrellas",
"stars": "Apoya la biblioteca con una estrella",
"version": "Versión",
"lastUpdate": "Última actualización",
"repository": "Repositorio",
"license": "Licencia",
"issues": "Cuestiones",
"maintainers": "Mantenedores",
"contributors": "Colaboradores"
}
}
4 changes: 2 additions & 2 deletions public/locales/ru/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"readme": "Readme",
"changelog": "Changelog",
"about": "О библиотеке",
"stars": "Звёзды",
"stars": "Поддержите библиотеку звёздочкой",
"version": "Версия",
"lastUpdate": "Последнее обновление",
"repository": "Репозиторий",
"license": "Лицензия",
"issues": "Задачи",
"maintainers": "Maintainers",
"contributors": "Участники"
}
}
4 changes: 2 additions & 2 deletions public/locales/zh/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"readme": "自述文件",
"changelog": "变更日志",
"about": "关于图书馆",
"stars": "明星",
"stars": "用星星支持图书馆",
"version": "版本",
"lastUpdate": "上次更新",
"repository": "存储库",
"license": "执照",
"issues": "问题",
"maintainers": "维护者",
"contributors": "贡献者"
}
}
39 changes: 39 additions & 0 deletions src/components/GitHubStarButton/GitHubStarButton.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@use '../../variables.scss';

$block: '.#{variables.$ns}github-star-button';

#{$block} {
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
border-radius: 8px;
transition: opacity 0.2s ease;
background: rgba(255, 255, 255, 1);
color: var(--g-color-text-dark-primary);
height: 36px;
width: 136px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

min-width?


&:hover {
opacity: 0.8;
}

&__button {
display: flex;
align-items: center;
gap: 4px;
padding: 5px 8px;
border: none;
color: var(--g-color-text-dark-primary);
}

&__divider {
width: 1px;
background: rgba(217, 217, 217, 1);
height: 20px;
}

&__count {
padding: 5px 8px;
}
}
40 changes: 40 additions & 0 deletions src/components/GitHubStarButton/GitHubStarButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {Icon, Text} from '@gravity-ui/uikit';
import React from 'react';

import githubIcon from '../../assets/icons/github.svg';

import './GitHubStarButton.scss';

const block = (name: string) => `gravity-ui-landing-github-star-button${name ? `__${name}` : ''}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use this block plz

const b = block;

interface GitHubStarButtonProps {
githubId: string;
starCount: number;
}

export const GitHubStarButton: React.FC<GitHubStarButtonProps> = ({githubId, starCount}) => {
const githubUrl = `https://github.com/${githubId}`;

const formatStarCount = (count: number): string => {
if (count >= 1000) {
return `${(count / 1000).toFixed(1)}k`;
}
return count.toString();
};

return (
<a href={githubUrl} target="_blank" rel="noopener noreferrer" className={b('')}>
<div className={b('button')}>
<Icon data={githubIcon} size={20} className={b('icon')} />
<Text variant="body-1" className={b('text')}>
Stars
</Text>
</div>
<div className={b('divider')} />
<Text variant="body-1" className={b('count')}>
{formatStarCount(starCount)}
</Text>
</a>
);
};
1 change: 1 addition & 0 deletions src/components/GitHubStarButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {GitHubStarButton} from './GitHubStarButton';
43 changes: 43 additions & 0 deletions src/components/Library/Library.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $block: '.#{variables.$ns}library';
& &__header-grid {
.container-fluid {
padding: 0;

.col {
padding: 0;
}
Expand Down Expand Up @@ -245,6 +246,48 @@ $block: '.#{variables.$ns}library';
}
}

&__info-item_github-star {
padding: 16px;

&:first-child {
margin-top: 16px;
}
}

&__github-star-content {
display: flex;
flex-direction: column;
gap: 12px;
width: 100%;
}

&__github-star-text {
display: flex;
width: 100%;
}

&__github-star-mobile {
display: none;

@media (max-width: map-get(pcVariables.$gridBreakpoints, 'lg') - 1) {
display: flex;
justify-content: center;
padding-right: 16px;

&_mobile-invisible {
display: none;
}
}
}

&__github-star-title {
font-size: 13px;
line-height: 18px;
font-weight: 400;
color: rgba(255, 255, 255, 0.6);
text-align: center;
}

&__contributors-content {
display: block;

Expand Down
37 changes: 36 additions & 1 deletion src/components/Library/Library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import starIcon from '../../assets/icons/star.svg';
import storybookIcon from '../../assets/icons/storybook.svg';
import versionIcon from '../../assets/icons/version.svg';
import {ContributorList} from '../../components/ContributorList';
import {GitHubStarButton} from '../../components/GitHubStarButton';
import {Link} from '../../components/Link';
import {useLocale} from '../../hooks/useLocale';
import {availablePlaygrounds} from '../../pages/libraries/[libId]/playground';
Expand Down Expand Up @@ -60,7 +61,6 @@ export const Library: React.FC<Props> = ({lib}) => {
{
id: 'stars',
title: t('library:stars'),
value: lib.metadata.stars,
icon: starIcon,
},
{
Expand Down Expand Up @@ -258,6 +258,18 @@ export const Library: React.FC<Props> = ({lib}) => {
}}
>
<div className={b('info-title-text')}>{t('library:about')}</div>

<div
className={b('github-star-mobile', {
'mobile-invisible': isVisibleInfoListMobile,
})}
>
<GitHubStarButton
githubId={lib.config.githubId}
starCount={lib.metadata.stars}
/>
</div>

<div
className={b('info-title-icon', {
'mobile-visible': isVisibleInfoListMobile,
Expand Down Expand Up @@ -310,6 +322,29 @@ export const Library: React.FC<Props> = ({lib}) => {
);
}

if (item.id === 'stars') {
return (
<div
key={item.id}
className={b('info-item', {
'github-star': true,
})}
>
<div className={b('github-star-content')}>
<div className={b('github-star-text')}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Center the text plz:
image

{content}
</div>
{isVisibleInfoListMobile && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's hidden on desktop:
image

<GitHubStarButton
githubId={lib.config.githubId}
starCount={lib.metadata.stars}
/>
)}
</div>
</div>
);
}

return (
<div key={item.id} className={b('info-item')}>
{content}
Expand Down
Loading