-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from Elastic-Suite/feat-1204557-PreviewGridDe…
…signSystem feat: #1204557 Boost Preview Grid Component Design system
- Loading branch information
Showing
28 changed files
with
1,558 additions
and
65 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
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
16 changes: 16 additions & 0 deletions
16
packages/components/src/components/atoms/form/PreviewGridBoostConfiguration.stories.tsx
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,16 @@ | ||
import React from 'react' | ||
import { ComponentMeta, ComponentStory } from '@storybook/react' | ||
import PreviewGridBoostConfigurationComponent from './PreviewGridBoostConfiguration' | ||
|
||
export default { | ||
title: 'Atoms/Form/PreviewGridBoostConfiguration', | ||
component: PreviewGridBoostConfigurationComponent, | ||
} as ComponentMeta<typeof PreviewGridBoostConfigurationComponent> | ||
|
||
const Template: ComponentStory< | ||
typeof PreviewGridBoostConfigurationComponent | ||
> = () => { | ||
return <PreviewGridBoostConfigurationComponent /> | ||
} | ||
|
||
export const PreviewGridBoostConfiguration = Template.bind({}) |
108 changes: 108 additions & 0 deletions
108
packages/components/src/components/atoms/form/PreviewGridBoostConfiguration.tsx
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,108 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import PreviewBoostingTable from '../../organisms/PreviewBoostingTable/PreviewBoostingTable' | ||
import FiltersPreviewBoostingTabs, { | ||
IPreviewBoostFilter, | ||
} from '../../molecules/FiltersPreviewBoostingTabs/FiltersPreviewBoostingTabs' | ||
import { useTranslation } from 'react-i18next' | ||
import { ITreeItem } from '@elastic-suite/gally-admin-shared' | ||
import { styled } from '@mui/material' | ||
import Pagination from '../../molecules/CustomTable/Pagination/Pagination' | ||
|
||
import productsMock from '../../../../public/mocks/boosts_preview_bags_search.json' | ||
import categoriesMock from '../../../../public/mocks/categories.json' | ||
|
||
const PreviewContainer = styled('div')(({ theme }) => ({ | ||
borderRadius: theme.shape.borderRadius, | ||
padding: theme.spacing(2), | ||
paddingBottom: theme.spacing(4), | ||
fontFamily: 'Inter', | ||
backgroundColor: '#E2E6F3', | ||
overflow: 'hidden', | ||
|
||
'.previewArea': { | ||
margin: 0, | ||
padding: 0, | ||
fontSize: '12px', | ||
fontFamily: 'var(--gally-font)', | ||
lineHeight: '18px', | ||
color: theme.palette.colors.neutral['600'], | ||
}, | ||
})) | ||
|
||
export default function PreviewGridBoostConfiguration(): JSX.Element { | ||
const [filter, setFilter] = useState<IPreviewBoostFilter>({ | ||
type: 'search', | ||
value: '', | ||
}) | ||
const [products, setProducts] = useState< | ||
| { | ||
id: string | ||
resultsAfter: any | ||
resultsBefore: any | ||
} | ||
| undefined | ||
>(undefined) | ||
const [categories, setCategories] = useState<ITreeItem[]>([]) | ||
const [currentPage, setCurrentPage] = useState<number>(0) | ||
const [count, setCount] = useState<number>(0) | ||
const rowsPerPage = 20 | ||
const { t } = useTranslation('boost') | ||
|
||
useEffect(() => { | ||
// TODO : Replace by GRAPHQL request | ||
setProducts(undefined) | ||
if (filter.value) { | ||
setProducts(productsMock.data.previewBoost) | ||
setCount(productsMock.data.previewBoost.resultsAfter.length) | ||
setCurrentPage(0) | ||
} | ||
}, [filter]) | ||
|
||
useEffect(() => { | ||
// TODO: Replace by GRAPHQL request | ||
setCategories(categoriesMock.categories) | ||
}, []) | ||
|
||
return ( | ||
<> | ||
<FiltersPreviewBoostingTabs | ||
onSendFilter={setFilter} | ||
categories={categories} | ||
/> | ||
{Boolean(products) && ( | ||
<> | ||
<Pagination | ||
style={{ | ||
borderRadius: '8px', | ||
marginBottom: '16px', | ||
marginTop: '32px', | ||
}} | ||
currentPage={currentPage} | ||
onPageChange={setCurrentPage} | ||
rowsPerPage={rowsPerPage} | ||
count={count} | ||
rowsPerPageOptions={[]} | ||
withResults | ||
/> | ||
<PreviewContainer> | ||
<p className="previewArea">{t('previewArea')}</p> | ||
<PreviewBoostingTable | ||
productsBefore={products?.resultsBefore} | ||
productsAfter={products?.resultsAfter} | ||
/> | ||
<Pagination | ||
style={{ padding: '0 16px', border: 'none' }} | ||
currentPage={currentPage} | ||
onPageChange={setCurrentPage} | ||
rowsPerPage={rowsPerPage} | ||
count={count} | ||
rowsPerPageOptions={[]} | ||
withResults | ||
isBottom | ||
/> | ||
</PreviewContainer> | ||
</> | ||
)} | ||
</> | ||
) | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/components/src/components/atoms/form/SearchBar.stories.tsx
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,34 @@ | ||
import React, { useState } from 'react' | ||
import { ComponentMeta, ComponentStory } from '@storybook/react' | ||
|
||
import SearchBarComponent from './SearchBar' | ||
import { action } from '@storybook/addon-actions' | ||
|
||
export default { | ||
title: 'Atoms/Form/SearchBar', | ||
component: SearchBarComponent, | ||
} as ComponentMeta<typeof SearchBarComponent> | ||
|
||
const Template: ComponentStory<typeof SearchBarComponent> = ({ | ||
value, | ||
...args | ||
}) => { | ||
const [val, setVal] = useState(value) | ||
const sendFilter = action('send Filter') | ||
|
||
return ( | ||
<SearchBarComponent | ||
{...args} | ||
value={val} | ||
onChange={setVal} | ||
onResearch={(): void => sendFilter(val)} | ||
/> | ||
) | ||
} | ||
|
||
export const SearchBar = Template.bind({}) | ||
|
||
SearchBar.args = { | ||
value: '', | ||
placeholder: 'Rechercher', | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/components/src/components/atoms/form/SearchBar.tsx
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,40 @@ | ||
import InputText from './InputText' | ||
import { InputAdornment } from '@mui/material' | ||
import IonIcon from '../IonIcon/IonIcon' | ||
import React, { FormEvent } from 'react' | ||
|
||
export default function SearchBar({ | ||
value, | ||
onChange, | ||
onResearch, | ||
placeholder, | ||
}: { | ||
value: string | ||
onChange: (value: string) => void | ||
onResearch: () => void | ||
placeholder: string | ||
}): JSX.Element { | ||
const handleSubmit = (event: FormEvent): void => { | ||
event.preventDefault() | ||
onResearch() | ||
} | ||
|
||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<InputText | ||
value={value} | ||
onChange={(value: string | number): void => onChange(value.toString())} | ||
placeholder={placeholder} | ||
endAdornment={ | ||
<InputAdornment | ||
position="end" | ||
onClick={onResearch} | ||
sx={{ cursor: 'pointer' }} | ||
> | ||
<IonIcon name="search" /> | ||
</InputAdornment> | ||
} | ||
/> | ||
</form> | ||
) | ||
} |
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.