-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
front: create power restriction grid modal
- Loading branch information
1 parent
8a557c5
commit bf4e61b
Showing
17 changed files
with
428 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
.d-flex .select-improved { | ||
flex-grow:4 | ||
flex-grow: 4; | ||
} | ||
|
||
.add-border-top { | ||
border-top: var(--coolgray3) solid 1px; | ||
border-top-right-radius: 0.4375rem; | ||
border-top-left-radius: 0.4375rem; | ||
} |
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 |
---|---|---|
@@ -1,34 +1,53 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
import './Grid.scss'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type GridProps = { | ||
data: string[]; | ||
gridData: string[]; | ||
filter?: string; | ||
extraClass?: string; | ||
updateData: (data: string) => void; | ||
selectorData?: (string | null)[]; | ||
}; | ||
|
||
function isFiltered(item: string, filter: string): boolean { | ||
return filter !== '' && !item.toLocaleLowerCase().includes(filter.toLocaleLowerCase()); | ||
} | ||
|
||
const Grid = ({ data, filter, extraClass, updateData }: GridProps) => ( | ||
<div className={`grid-list ${extraClass}`}> | ||
{data.map((item, i) => ( | ||
<button | ||
key={i} | ||
type="button" | ||
title={item} | ||
className={cx('grid-item', { | ||
filtered: filter && isFiltered(item, filter), | ||
})} | ||
onClick={() => updateData(item)} | ||
> | ||
{item} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
function isInSelector(data: (string | null)[], item: string) { | ||
return data.includes(item); | ||
} | ||
|
||
const Grid = ({ gridData, filter, extraClass, updateData, selectorData }: GridProps) => { | ||
const { t } = useTranslation('translation'); | ||
return ( | ||
<div className={`grid-list ${extraClass}`}> | ||
{gridData.map((item, i) => ( | ||
<button | ||
key={i} | ||
type="button" | ||
disabled={selectorData && isInSelector(selectorData, item)} | ||
title={`${item} ${ | ||
selectorData && isInSelector(selectorData, item) ? t('common.selected') : '' | ||
}`} | ||
className={cx('grid-item', { | ||
filtered: filter && isFiltered(item, filter), | ||
present: selectorData && isInSelector(selectorData, item), | ||
})} | ||
onClick={() => updateData(item)} | ||
> | ||
<span | ||
className={cx({ | ||
present: selectorData && isInSelector(selectorData, item), | ||
})} | ||
> | ||
{item} | ||
</span> | ||
</button> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Grid; |
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.