-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add github stars promotion block to landing (#207)
* DATAUI-2207: add github stars promotion block to landing
- Loading branch information
Showing
10 changed files
with
165 additions
and
15 deletions.
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