-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: add github stars promotion block #207
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e8bf6cc
DATAUI-2207: add github stars to landing
shbov 7750431
DATAUI-2207: add github stars to landing
shbov 2f8a9f3
Merge branch 'shbovv/add_github_stars' of https://github.com/gravity-…
shbov b4fbf99
set default state
shbov c340152
design fixes
shbov b213950
update styles
shbov fb69348
Update home.json
shbov 90103bd
Update home.json
shbov ed4869c
hide block on rtl
shbov 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
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,73 @@ | ||
@use '~@gravity-ui/page-constructor/styles/styles.scss' as pcStyles; | ||
@use '~@gravity-ui/page-constructor/styles/variables.scss' as pcVariables; | ||
@use '../../variables.scss'; | ||
|
||
$block: '.#{variables.$ns}github-stars-promotion'; | ||
|
||
.pc-block-base.pc-block-base.pc-block-base.pc-constructor-block_type_github-stars-promotion { | ||
position: unset; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#{$block} { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: var(--g-spacing-2); | ||
padding: var(--g-spacing-1) var(--g-spacing-1) var(--g-spacing-1) var(--g-spacing-4); | ||
border-radius: var(--g-border-radius-m); | ||
text-decoration: none; | ||
background: #cda2e7; | ||
|
||
@media (min-width: map-get(pcVariables.$gridBreakpoints, 'sm')) { | ||
transform: translateX(calc(100% + 2 * var(--g-spacing-2))); | ||
animation: leftBlockAnimation 250ms ease-out forwards; | ||
animation-delay: 500ms; | ||
} | ||
|
||
&__wrapper { | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
|
||
padding-top: var(--g-spacing-2); | ||
|
||
@media (min-width: map-get(pcVariables.$gridBreakpoints, 'sm')) { | ||
position: absolute; | ||
overflow: hidden; | ||
left: 0; | ||
right: 0; | ||
z-index: 9; | ||
|
||
padding-left: var(--g-spacing-2); | ||
padding-right: var(--g-spacing-2); | ||
|
||
&[data-hide='true'] { | ||
display: none; | ||
} | ||
|
||
&[data-device='mobile'] { | ||
display: none; | ||
} | ||
} | ||
|
||
@media (max-width: map-get(pcVariables.$gridBreakpoints, 'sm') - 1) { | ||
justify-content: center; | ||
|
||
&[data-device='desktop'] { | ||
display: none; | ||
} | ||
} | ||
} | ||
|
||
@keyframes leftBlockAnimation { | ||
from { | ||
transform: translateX(100%); | ||
} | ||
|
||
to { | ||
transform: translateX(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {Star} from '@gravity-ui/icons'; | ||
import {Animatable, HTML} from '@gravity-ui/page-constructor'; | ||
import {Button, Icon, Text} from '@gravity-ui/uikit'; | ||
import {useTranslation} from 'next-i18next'; | ||
import {useRouter} from 'next/router'; | ||
import React, {useEffect, useState} from 'react'; | ||
import {GITHUB_UI_KIT_URL} from 'src/constants'; | ||
|
||
import {block} from '../../utils'; | ||
import {CustomBlock} from '../constants'; | ||
|
||
import './GithubStarsBlock.scss'; | ||
|
||
const b = block('github-stars-promotion'); | ||
const LOCAL_STORAGE_KEY = 'gravity-landing-hide-stars-promotion'; | ||
|
||
type GithubStarsBlockProps = Animatable & { | ||
device: 'desktop' | 'mobile'; | ||
}; | ||
|
||
export type GithubStarsModel = GithubStarsBlockProps & { | ||
type: CustomBlock.GithubStars; | ||
}; | ||
|
||
export const GithubStarsBlock: React.FC<GithubStarsBlockProps> = ({device}) => { | ||
const {t} = useTranslation(); | ||
const {pathname} = useRouter(); | ||
const [hide, setHide] = useState<boolean>(true); | ||
|
||
useEffect(() => { | ||
setHide(Boolean(localStorage.getItem(LOCAL_STORAGE_KEY))); | ||
}, []); | ||
|
||
const hideBlock = () => { | ||
localStorage.setItem(LOCAL_STORAGE_KEY, 'true'); | ||
}; | ||
|
||
if (pathname !== '/') { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className={b('wrapper')} data-hide={hide} data-device={device}> | ||
<a className={b()} href={GITHUB_UI_KIT_URL} target="_blank" onClick={hideBlock}> | ||
<Text color="dark-primary" variant="body-2"> | ||
<HTML>{t('home:github_stars-text')}</HTML> | ||
</Text> | ||
|
||
<Button view="normal-contrast" size="m" tabIndex={-1}> | ||
<Icon data={Star} size={16} /> | ||
<Text variant="body-1">{t('home:github_stars-button')}</Text> | ||
</Button> | ||
</a> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GithubStarsBlock; |
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 |
---|---|---|
|
@@ -24,6 +24,7 @@ $block: '.#{variables.$ns}layout'; | |
} | ||
|
||
&__content { | ||
position: relative; | ||
flex: 1; | ||
} | ||
} |
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.
Let's hide this block for rtl landing or adapt it for rtl.
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.
fixed both comments