forked from morfeojs/morfeo
-
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.
Showing
17 changed files
with
257 additions
and
50 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
50 changes: 42 additions & 8 deletions
50
devtool/src/_shared/components/Slices/Components/Detail/index.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 |
---|---|---|
@@ -1,30 +1,64 @@ | ||
import { Component } from '@morfeo/react'; | ||
import { Color, Component, component, morfeo } from '@morfeo/react'; | ||
import clsx from 'clsx'; | ||
import { useMemo, useState, useCallback } from 'react'; | ||
import { useRouter } from '../../../../hooks'; | ||
import { MorfeoComponent } from '../MorfeoComponent'; | ||
|
||
import styles from './style.module.css'; | ||
import { Card } from '../../../Card'; | ||
import { Icon } from '../../../Icon'; | ||
|
||
export const Detail = () => { | ||
const { route } = useRouter(); | ||
const { state } = route; | ||
const { detailKey: componentName = '', componentVariant } = state || {}; | ||
const { meta } = | ||
component(componentName as Component, componentVariant).get() || {}; | ||
const { devtoolConfig } = meta || {}; | ||
const [defaultStyleActive, setDefaultStyleActive] = useState(true); | ||
|
||
const currentThemeName = morfeo.getCurrent(); | ||
|
||
const computedBackground = useMemo(() => { | ||
if (typeof devtoolConfig?.background === 'object') { | ||
return devtoolConfig?.background[currentThemeName]; | ||
} | ||
return (devtoolConfig?.background as Color) || ('#fff' as Color); | ||
}, [currentThemeName, devtoolConfig?.background]); | ||
|
||
const onDefaultStyleCheckboxChange = useCallback(() => { | ||
setDefaultStyleActive(state => !state); | ||
}, []) | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div | ||
className={clsx( | ||
'morfeo-card-primary-clickable', | ||
styles.previewContainer, | ||
)} | ||
{devtoolConfig?.style && ( | ||
<div className={styles.defaultStyleAlertContainer}> | ||
<input type="checkbox" checked={defaultStyleActive} onChange={onDefaultStyleCheckboxChange} /> | ||
<div className="ml-xxs"> | ||
<Icon name="warning" /> | ||
</div> | ||
<h4 className="morfeo-typography-h4"> | ||
Web extension default style | ||
</h4> | ||
<div> | ||
<Icon name="warning" /> | ||
</div> | ||
</div> | ||
)} | ||
<Card | ||
className={clsx('morfeo-card-primary', styles.previewContainer)} | ||
style={{ | ||
bg: computedBackground, | ||
}} | ||
> | ||
<MorfeoComponent | ||
applyDefaultStyle={defaultStyleActive} | ||
name={componentName as Component} | ||
variant={componentVariant} | ||
> | ||
{componentName} | ||
</MorfeoComponent> | ||
</div> | ||
</Card> | ||
</div> | ||
); | ||
}; |
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
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,35 @@ | ||
import { ComponentConfig } from '@morfeo/react'; | ||
|
||
export const Box: ComponentConfig = { | ||
tag: 'div', | ||
style: { | ||
fontFamily: 'regular' | ||
}, | ||
variants: { | ||
flexRow: { | ||
style: { | ||
display: 'flex', | ||
flexDirection: 'row' | ||
} | ||
}, | ||
flexColumn: { | ||
style: { | ||
flexDirection: 'column' | ||
} | ||
} | ||
}, | ||
meta: { | ||
description: 'a simple div', | ||
devtoolConfig: { | ||
background: 'background', | ||
style: { | ||
width: '80px', | ||
height: '80px', | ||
backgroundColor: 'gray.lighter', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
} | ||
} | ||
} | ||
} as ComponentConfig; |
Oops, something went wrong.