-
Notifications
You must be signed in to change notification settings - Fork 1
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 #178 from open-formulieren/refactor/preview-to-pan…
…el-preview Refactor preview to panel preview
- Loading branch information
Showing
43 changed files
with
194 additions
and
191 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
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,80 @@ | ||
import {ColumnsComponentSchema} from '@open-formulieren/types'; | ||
import clsx from 'clsx'; | ||
import {useState} from 'react'; | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import ModeToggle from '@/components/ModeToggle'; | ||
|
||
import {ComponentPreviewProps} from '../types'; | ||
|
||
type ViewportMode = 'desktop' | 'mobile'; | ||
|
||
/** | ||
* Show a formio columns component preview. | ||
*/ | ||
const Preview: React.FC<ComponentPreviewProps<ColumnsComponentSchema>> = ({component}) => { | ||
const [viewportMode, setViewportMode] = useState<ViewportMode>('desktop'); | ||
|
||
const {columns} = component; | ||
const isMobile = viewportMode === 'mobile'; | ||
return ( | ||
<> | ||
<div className="d-flex justify-content-end align-items-center"> | ||
<ModeToggle<ViewportMode> | ||
name="previewViewport" | ||
currentMode={viewportMode} | ||
btnClassName="btn-light" | ||
onToggle={setViewportMode} | ||
modes={[ | ||
{ | ||
value: 'desktop', | ||
label: ( | ||
<FormattedMessage | ||
description="Columns 'desktop' preview viewport" | ||
defaultMessage="Default" | ||
/> | ||
), | ||
}, | ||
{ | ||
value: 'mobile', | ||
label: ( | ||
<FormattedMessage | ||
description="Columns 'mobile' preview viewport" | ||
defaultMessage="Mobile" | ||
/> | ||
), | ||
}, | ||
]} | ||
/> | ||
</div> | ||
|
||
<div | ||
className={clsx('offb-columns-panel-preview', { | ||
'offb-columns-panel-preview--mobile': isMobile, | ||
})} | ||
> | ||
{columns.map((column, index) => ( | ||
<div | ||
key={`column-${index}`} | ||
className="offb-columns-panel-preview__column" | ||
style={ | ||
{ | ||
'--_col-preview-span': `${isMobile ? column.sizeMobile : column.size}`, | ||
} as React.CSSProperties | ||
} | ||
> | ||
<FormattedMessage | ||
description="Column preview column description" | ||
defaultMessage="Column {number}" | ||
values={{ | ||
number: index + 1, | ||
}} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Preview; |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/registry/columns/preview.scss → src/registry/columns/previews.scss
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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.