-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
240 additions
and
9 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
@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}templates-block'; | ||
|
||
#{$block} { | ||
@include pcStyles.animate(); | ||
|
||
&__title { | ||
@include pcStyles.heading2(); | ||
margin-bottom: pcVariables.$indentM; | ||
} | ||
} |
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,33 @@ | ||
import {Animatable, AnimateBlock, HTML} from '@gravity-ui/page-constructor'; | ||
import React from 'react'; | ||
|
||
import {Templates} from '../../components/Templates'; | ||
import type {Tab} from '../../components/Templates'; | ||
import {block} from '../../utils'; | ||
import {CustomBlock} from '../constants'; | ||
|
||
import './TemplatesBlock.scss'; | ||
|
||
const b = block('templates-block'); | ||
|
||
export type TemplatesProps = Animatable & { | ||
title: string; | ||
tabs: Tab[]; | ||
}; | ||
|
||
export type TemplatesModel = TemplatesProps & { | ||
type: CustomBlock.Templates; | ||
}; | ||
|
||
export const TemplatesBlock: React.FC<TemplatesProps> = ({animated, title, tabs}) => { | ||
return ( | ||
<AnimateBlock className={b()} animate={animated}> | ||
<h2 className={b('title')} data-section="templates"> | ||
<HTML>{title}</HTML> | ||
</h2> | ||
<Templates tabs={tabs} /> | ||
</AnimateBlock> | ||
); | ||
}; | ||
|
||
export default TemplatesBlock; |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@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}templates'; | ||
|
||
#{$block} { | ||
background: #251b25; | ||
border-radius: pcVariables.$borderRadius; | ||
padding: 12px 32px 24px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
|
||
&__commands-wrapper { | ||
width: 100%; | ||
padding: 16px; | ||
background: #160d1b; | ||
border-radius: 16px; | ||
|
||
@media (max-width: map-get(pcVariables.$gridBreakpoints, 'lg') - 1) { | ||
width: inherit; | ||
} | ||
} | ||
|
||
&__commands { | ||
overflow-x: auto; | ||
white-space: nowrap; | ||
position: relative; | ||
} | ||
|
||
&__copy { | ||
position: absolute; | ||
top: 0; | ||
right: 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,74 @@ | ||
import {Button, ClipboardButton, Icon, Tabs, Text} from '@gravity-ui/uikit'; | ||
import React from 'react'; | ||
|
||
import {block} from '../../utils'; | ||
|
||
import './Templates.scss'; | ||
import type {Tab} from './types'; | ||
|
||
const b = block('templates'); | ||
|
||
interface CommandsProps { | ||
commands: string[]; | ||
} | ||
|
||
const Commands: React.FC<CommandsProps> = ({commands}) => { | ||
return ( | ||
<div className={b('commands-wrapper')}> | ||
<div className={b('commands')}> | ||
{commands.map((item, index) => { | ||
return ( | ||
<Text as="div" key={index} variant="body-3"> | ||
{item} | ||
</Text> | ||
); | ||
})} | ||
<ClipboardButton text={commands.join(' && ')} className={b('copy')} size={16} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
interface TabContentProps { | ||
data?: Pick<Tab, 'button' | 'commands'>; | ||
} | ||
|
||
const TabContent: React.FC<TabContentProps> = ({data}) => { | ||
if (!data) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{data.commands && <Commands commands={data.commands} />} | ||
{data.button?.href && ( | ||
<div> | ||
<Button {...data.button} pin="circle-circle" view="outlined-action" size="xl"> | ||
{data.button.title} | ||
</Button> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
interface TemplatesProps { | ||
tabs: Tab[]; | ||
} | ||
|
||
export const Templates: React.FC<TemplatesProps> = ({tabs}) => { | ||
const [activeTab, setActiveTab] = React.useState(() => tabs[0]?.title); | ||
const tabsItems = tabs.map(({title, icon}) => ({ | ||
id: title, | ||
title, | ||
icon: icon ? <Icon data={icon} size={24} /> : undefined, | ||
})); | ||
const activeTabData = tabs.find((el) => el.title === activeTab); | ||
|
||
return ( | ||
<section className={b()}> | ||
<Tabs size="xl" items={tabsItems} activeTab={activeTab} onSelectTab={setActiveTab} /> | ||
<TabContent data={activeTabData} /> | ||
</section> | ||
); | ||
}; |
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,3 @@ | ||
export type {Tab} from './types'; | ||
|
||
export {Templates} from './Templates'; |
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,12 @@ | ||
import {SVGIconData} from '@gravity-ui/uikit/build/esm/components/Icon/types'; | ||
|
||
export interface Tab { | ||
title: string; | ||
icon?: SVGIconData; | ||
commands?: string[]; | ||
button?: { | ||
title: string; | ||
href?: string; | ||
target?: string; | ||
}; | ||
} |
Oops, something went wrong.