Add common gutter styles as hook
This commit is contained in:
@@ -20,6 +20,7 @@ export * from '#/alf/types'
|
|||||||
export * from '#/alf/util/flatten'
|
export * from '#/alf/util/flatten'
|
||||||
export * from '#/alf/util/platform'
|
export * from '#/alf/util/platform'
|
||||||
export * from '#/alf/util/themeSelector'
|
export * from '#/alf/util/themeSelector'
|
||||||
|
export * from '#/alf/util/useGutterStyles'
|
||||||
|
|
||||||
export type Alf = {
|
export type Alf = {
|
||||||
themeName: ThemeName
|
themeName: ThemeName
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import {atoms as a, useBreakpoints, ViewStyleProp} from '#/alf'
|
||||||
|
|
||||||
|
export function useGutterStyles({
|
||||||
|
top,
|
||||||
|
bottom,
|
||||||
|
}: {
|
||||||
|
top?: boolean
|
||||||
|
bottom?: boolean
|
||||||
|
} = {}) {
|
||||||
|
const {gtMobile} = useBreakpoints()
|
||||||
|
return React.useMemo<ViewStyleProp['style']>(() => {
|
||||||
|
return [
|
||||||
|
a.px_lg,
|
||||||
|
top && a.pt_md,
|
||||||
|
bottom && a.pb_md,
|
||||||
|
gtMobile && [a.px_xl, top && a.pt_lg, bottom && a.pb_lg],
|
||||||
|
]
|
||||||
|
}, [gtMobile, top, bottom])
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user