-
Notifications
You must be signed in to change notification settings - Fork 31
add button "star project" for all projects #457
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
Open
anton129
wants to merge
2
commits into
gravity-ui:main
Choose a base branch
from
anton129:star-project
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.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,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; | ||
|
|
||
| &: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; | ||
| } | ||
| } | ||
This file contains hidden or 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,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}` : ''}`; | ||
|
Collaborator
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. 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> | ||
| ); | ||
| }; | ||
This file contains hidden or 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 @@ | ||
| export {GitHubStarButton} from './GitHubStarButton'; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -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'; | ||
|
|
@@ -60,7 +61,6 @@ export const Library: React.FC<Props> = ({lib}) => { | |
| { | ||
| id: 'stars', | ||
| title: t('library:stars'), | ||
| value: lib.metadata.stars, | ||
| icon: starIcon, | ||
| }, | ||
| { | ||
|
|
@@ -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, | ||
|
|
@@ -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')}> | ||
|
Collaborator
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. |
||
| {content} | ||
| </div> | ||
| {isVisibleInfoListMobile && ( | ||
|
Collaborator
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. |
||
| <GitHubStarButton | ||
| githubId={lib.config.githubId} | ||
| starCount={lib.metadata.stars} | ||
| /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div key={item.id} className={b('info-item')}> | ||
| {content} | ||
|
|
||
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.
min-width?