Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const HeightControl = ({
}: {
selectedLayoutId: Layout
setInitialLayout: (layoutId: Layout) => void
heightValue: number | undefined
setHeightValue: (height: number | undefined) => void
heightValue: number | 'fit-content' | undefined
setHeightValue: (height: number | 'fit-content' | undefined) => void
}) => {
const { setHeader, setContainer, getCurrentConfigTheme } = useConfigActions()

Expand Down Expand Up @@ -87,7 +87,7 @@ export const HeightControl = ({
)
}

if (selectedLayoutId === 'fit-content') {
if (selectedLayoutId === 'default') {
return (
<PlaygroundControlsContainer sx={{ gap: 0 }}>
<InputControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CapitalizeFirstLetter, Input } from '../DesignControls.style.js'

interface InputControlProps extends HTMLAttributes<HTMLDivElement> {
label: string
value: number | undefined
value: number | 'fit-content' | undefined
onChange: ChangeEventHandler<HTMLInputElement>
onBlur: FocusEventHandler<HTMLInputElement>
}
Expand All @@ -22,11 +22,13 @@ export const InputControl = ({
onBlur,
}: InputControlProps) => {
const inputId = useId()
const showCaption =
!value || value === 'fit-content' || value < defaultMaxHeight
return (
<CardRowContainer sx={{ padding: 1 }}>
<CardRowColumn>
<label htmlFor={inputId}>{label}</label>
{(value && value < defaultMaxHeight) || !value ? (
{showCaption ? (
<CapitalizeFirstLetter variant="caption">
{`${defaultMaxHeight}px minimum`}
</CapitalizeFirstLetter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ const layoutOptions: LayoutOption[] = [
id: 'full-height',
name: 'Full Height',
},
{
id: 'fit-content',
name: 'Fit Content',
},
]

const getLayoutMode = (container?: CSSProperties) => {
Expand All @@ -52,7 +48,7 @@ const getLayoutMode = (container?: CSSProperties) => {
if (container.display === 'flex' && container.height === '100%') {
layoutMode = 'full-height'
} else if (container.height === 'fit-content') {
layoutMode = 'fit-content'
layoutMode = 'default'
} else if (Number.isFinite(container.height)) {
layoutMode = 'restricted-height'
} else if (Number.isFinite(container.maxHeight)) {
Expand All @@ -72,7 +68,9 @@ export const LayoutControl = () => {

const { selectedLayoutId } = useLayoutValues()
const { setSelectedLayoutId } = useEditToolsActions()
const [heightValue, setHeightValue] = useState<number | undefined>() // height or maxHeight, depending on selectedLayoutId
const [heightValue, setHeightValue] = useState<
number | 'fit-content' | undefined
>() // height or maxHeight, depending on selectedLayoutId

useEffect(() => {
setSelectedLayoutId(getLayoutMode(config?.theme?.container))
Expand Down Expand Up @@ -127,28 +125,15 @@ export const LayoutControl = () => {
setContainer(fullHeightContainer)
break
}
case 'fit-content': {
setHeader()

const fullHeightContainer = {
...(getCurrentConfigTheme()?.container ?? {}),
display: undefined,
height: 'fit-content',
maxHeight: defaultMaxHeight,
}

setContainer(fullHeightContainer)
break
}
default: {
setHeightValue(undefined)
setHeightValue('fit-content')
setHeader()

const defaultContainer = {
...(getCurrentConfigTheme()?.container ?? {}),
display: undefined,
height: undefined,
maxHeight: undefined,
height: 'fit-content',
maxHeight: defaultMaxHeight,
}

setContainer(defaultContainer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ interface WidgetViewContainerProps extends PropsWithChildren {
toggleDrawer?(): void
}

const topAlignedLayouts: Layout[] = [
'default',
'restricted-max-height',
'fit-content',
]
const topAlignedLayouts: Layout[] = ['default', 'restricted-max-height']

export function WidgetViewContainer({
children,
Expand Down
1 change: 0 additions & 1 deletion packages/widget-playground/src/store/editTools/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export type Layout =
| 'restricted-height'
| 'restricted-max-height'
| 'full-height'
| 'fit-content'

export interface ThemeItem {
id: string
Expand Down
6 changes: 5 additions & 1 deletion packages/widget/src/themes/createTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export const createTheme = (widgetTheme: WidgetTheme = {}) => {
},
},
},
container: widgetTheme.container,
container: {
// Set height to 'fit-content' if not explicitly set
height: 'fit-content',
...widgetTheme.container,
},
routesContainer: widgetTheme.routesContainer,
chainSidebarContainer: widgetTheme.chainSidebarContainer,
header: widgetTheme.header,
Expand Down
Loading