Skip to content
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: Show the linked to tooltip on the item creation modal #3201

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/LinkedToTooltip/LinkedToToolip.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type Props = {
className?: string
}
64 changes: 64 additions & 0 deletions src/components/LinkedToTooltip/LinkedToTooltip.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.linkedTooltip {
display: grid;
width: 458px;
margin: 14px;
grid-template-columns: auto auto;
gap: 4px;
overflow: hidden;
}

.gridItem {
position: relative;
padding: 10px;
display: flex;
align-items: start;
}

.mappingExample {
color: #cfcdd4;
}

.mappingType {
display: flex;
align-items: center;
}

.mappingDescription {
flex-direction: column;
}

.mappingIcon {
width: 20px;
height: 20px;
margin-right: 10px;
}

.tooltipHeader {
display: flex;
align-items: center;
grid-column-start: 1;
grid-column-end: 3;
padding: 10px;
text-transform: uppercase;
}

.tooltipHeader img {
width: 20px;
height: 20px;
margin-right: 10px;
}

.gridItem::before,
.gridItem::after {
content: '';
position: absolute;
background-color: #a09ba8;
z-index: 1;
}

.gridItem::after {
width: 100vw;
height: 1px;
left: 0;
top: -1px;
}
50 changes: 50 additions & 0 deletions src/components/LinkedToTooltip/LinkedToTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import classNames from 'classnames'
import { InfoTooltip } from 'decentraland-ui'
import { t } from 'decentraland-dapps/dist/modules/translation'
import { MappingType } from '@dcl/schemas'
import allIcon from '../../icons/all.svg'
import multipleIcon from '../../icons/multiple.svg'
import singleIcon from '../../icons/single.svg'
import rangeIcon from '../../icons/range.svg'
import lightbulbIcon from '../../icons/lightbulb.svg'
import styles from './LinkedToTooltip.module.css'
import { Props } from './LinkedToToolip.types'

const mappingTypeIcons = {
[MappingType.ANY]: allIcon,
[MappingType.MULTIPLE]: multipleIcon,
[MappingType.SINGLE]: singleIcon,
[MappingType.RANGE]: rangeIcon
}

const LinkingTooltipMappingType = ({ type }: { type: MappingType }) => {
return (
<>
<div className={styles.gridItem}>
<div className={styles.mappingType}>
<img className={styles.mappingIcon} src={mappingTypeIcons[type]} />
{t(`mapping_editor.mapping_types.${type}`)}
</div>
</div>
<div className={classNames(styles.gridItem, styles.mappingDescription)}>
<div>{t(`mapping_editor.mapping_descriptions.${type}`)}</div>
{type !== MappingType.ANY && <div className={styles.mappingExample}>{t(`mapping_editor.mapping_examples.${type}`)}</div>}
</div>
</>
)
}

export const LinkingToTooltip = ({ className }: Props) => (
<InfoTooltip className={className}>
<div className={styles.linkedTooltip}>
<div className={styles.tooltipHeader}>
<img src={lightbulbIcon} />
{t('collection_row.linking_tooltip.title')}
</div>
<LinkingTooltipMappingType type={MappingType.ANY} />
<LinkingTooltipMappingType type={MappingType.SINGLE} />
<LinkingTooltipMappingType type={MappingType.MULTIPLE} />
<LinkingTooltipMappingType type={MappingType.RANGE} />
</div>
</InfoTooltip>
)
1 change: 1 addition & 0 deletions src/components/LinkedToTooltip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LinkedToTooltip'
8 changes: 8 additions & 0 deletions src/components/MappingEditor/MappingEditor.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,11 @@
.mappings :global(.dcl.text-area) {
width: 100%;
}

/* Tooltip */

.typeLabel {
display: flex;
align-items: center;
gap: 6px;
}
9 changes: 8 additions & 1 deletion src/components/MappingEditor/MappingEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames'
import { DropdownProps, Field, InputOnChangeData, SelectField, TextAreaField, TextAreaProps } from 'decentraland-ui'
import { MappingType, MultipleMapping } from '@dcl/schemas'
import { t } from 'decentraland-dapps/dist/modules/translation'
import { LinkingToTooltip } from 'components/LinkedToTooltip'
import allIcon from '../../icons/all.svg'
import multipleIcon from '../../icons/multiple.svg'
import singleIcon from '../../icons/single.svg'
Expand Down Expand Up @@ -117,7 +118,13 @@ export const MappingEditor = (props: Props) => {
return (
<div className={classNames(styles.main, isCompact ? styles.compact : styles.full)}>
<SelectField
label={isCompact ? undefined : t('mapping_editor.mapping_type_label')}
label={
isCompact ? undefined : (
<div className={styles.typeLabel}>
{t('mapping_editor.mapping_type_label')} <LinkingToTooltip />
</div>
)
}
onChange={handleMappingTypeChange}
placeholder={t('mapping_editor.mapping_type_placeholder')}
value={mappingType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
visibility: hidden !important;
}

.CreateSingleItemModalContainer > .ui.page.modals {
z-index: 1900;
}

.CreateSingleItemModal.ui.modal > .content {
margin-bottom: 32px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,6 @@
margin-right: 10px;
}

.linkedTooltip {
display: grid;
width: 458px;
margin: 14px;
grid-template-columns: auto auto;
gap: 4px;
overflow: hidden;
}

.gridItem {
position: relative;
padding: 10px;
display: flex;
align-items: start;
}

.mappingExample {
color: #cfcdd4;
}

.mappingType {
display: flex;
align-items: center;
}

.mappingDescription {
flex-direction: column;
}

.mappingIcon {
width: 20px;
height: 20px;
margin-right: 10px;
}

.tooltipHeader {
display: flex;
align-items: center;
grid-column-start: 1;
grid-column-end: 3;
padding: 10px;
text-transform: uppercase;
}

.tooltipHeader img {
width: 20px;
height: 20px;
margin-right: 10px;
}

.gridItem::before,
.gridItem::after {
content: '';
position: absolute;
background-color: #a09ba8;
z-index: 1;
}

.gridItem::after {
width: 100vw;
height: 1px;
left: 0;
top: -1px;
}

.linkedToColumn > span {
margin-right: 6px;
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
import classNames from 'classnames'
import { MappingType } from '@dcl/schemas'
import { Checkbox, Grid, InfoTooltip } from 'decentraland-ui'
import allIcon from '../../../icons/all.svg'
import multipleIcon from '../../../icons/multiple.svg'
import singleIcon from '../../../icons/single.svg'
import rangeIcon from '../../../icons/range.svg'
import lightbulbIcon from '../../../icons/lightbulb.svg'
import { Props } from './CollectionItemHeaderV2.types'
import { Checkbox, Grid } from 'decentraland-ui'
import { t } from 'decentraland-dapps/dist/modules/translation'
import { LinkingToTooltip } from 'components/LinkedToTooltip'
import { Props } from './CollectionItemHeaderV2.types'
import styles from './CollectionItemHeaderV2.module.css'

const mappingTypeIcons = {
[MappingType.ANY]: allIcon,
[MappingType.MULTIPLE]: multipleIcon,
[MappingType.SINGLE]: singleIcon,
[MappingType.RANGE]: rangeIcon
}

const LinkingTooltipMappingType = ({ type }: { type: MappingType }) => {
return (
<>
<div className={styles.gridItem}>
<div className={styles.mappingType}>
<img className={styles.mappingIcon} src={mappingTypeIcons[type]} />
{t(`mapping_editor.mapping_types.${type}`)}
</div>
</div>
<div className={classNames(styles.gridItem, styles.mappingDescription)}>
<div>{t(`mapping_editor.mapping_descriptions.${type}`)}</div>
{type !== MappingType.ANY && <div className={styles.mappingExample}>{t(`mapping_editor.mapping_examples.${type}`)}</div>}
</div>
</>
)
}

const LinkingTooltipContent = () => (
<div className={styles.linkedTooltip}>
<div className={styles.tooltipHeader}>
<img src={lightbulbIcon} />
{t('collection_row.linking_tooltip.title')}
</div>
<LinkingTooltipMappingType type={MappingType.ANY} />
<LinkingTooltipMappingType type={MappingType.SINGLE} />
<LinkingTooltipMappingType type={MappingType.MULTIPLE} />
<LinkingTooltipMappingType type={MappingType.RANGE} />
</div>
)

export const CollectionItemHeaderV2 = ({ areAllSelected, onSelectedAllClick }: Props) => {
return (
<Grid columns="equal" className={styles.gridHeader}>
Expand All @@ -58,9 +15,7 @@ export const CollectionItemHeaderV2 = ({ areAllSelected, onSelectedAllClick }: P
</Grid.Column>
<Grid.Column className={styles.linkedToColumn}>
<span>{t('third_party_collection_detail_page.linked_to')}</span>
<InfoTooltip>
<LinkingTooltipContent />
</InfoTooltip>
<LinkingToTooltip />
</Grid.Column>
<Grid.Column width={3}> {t('collection_row.status')} </Grid.Column>
<Grid.Column width={1}></Grid.Column>
Expand Down
Loading