Skip to content

Commit a136f96

Browse files
ENvironmentSetanakin_karrot
andauthored
feat(plugin-basic-ui): Expose <AppBar> sizing related style customization interfaces (#648)
Co-authored-by: anakin_karrot <anakin@daangn.com>
1 parent b0bbf6c commit a136f96

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

.changeset/clean-points-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackflow/plugin-basic-ui": minor
3+
---
4+
5+
Expose interfaces to modify dimensions of AppBar

extensions/plugin-basic-ui/src/basicUIPlugin.css.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ const GLOBAL_VARS = {
3030
"app-bar-background-image-transition-duration",
3131
overflow: "app-bar-overflow",
3232
minSafeAreaInsetTop: "app-bar-min-safe-area-inset-top",
33+
containerPadding: "app-bar-container-padding",
34+
itemGap: "app-bar-item-gap",
35+
fontSize: "app-bar-font-size",
36+
lineHeight: "app-bar-line-height",
37+
hitSlop: "app-bar-hit-slop",
3338
},
3439
bottomSheet: {
3540
borderRadius: "bottom-sheet-border-radius",
@@ -70,6 +75,11 @@ const androidValues: GlobalVars = {
7075
backgroundImageTransitionDuration: "0s",
7176
overflow: "hidden",
7277
minSafeAreaInsetTop: "0px",
78+
containerPadding: "1rem",
79+
itemGap: "1rem",
80+
fontSize: "1.125rem",
81+
hitSlop: "0.5rem",
82+
lineHeight: "1.5",
7383
},
7484
bottomSheet: {
7585
borderRadius: "1rem",
@@ -87,6 +97,7 @@ const cupertinoValues: GlobalVars = {
8797
height: "2.75rem",
8898
minHeight: "2.75rem",
8999
borderSize: "0.5px",
100+
lineHeight: "normal",
90101
},
91102
};
92103

extensions/plugin-basic-ui/src/basicUIPlugin.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export const basicUIPlugin: (
8585
[css.globalVars.bottomSheet.borderRadius]:
8686
_options.bottomSheet?.borderRadius,
8787
[css.globalVars.modal.borderRadius]: _options.modal?.borderRadius,
88+
[css.globalVars.appBar.containerPadding]:
89+
_options.appBar?.containerPadding,
90+
[css.globalVars.appBar.fontSize]: _options.appBar?.fontSize,
91+
[css.globalVars.appBar.lineHeight]: _options.appBar?.lineHeight,
92+
[css.globalVars.appBar.hitSlop]: _options.appBar?.hitSlop,
93+
[css.globalVars.appBar.itemGap]: _options.appBar?.itemGap,
8894
}),
8995
)}
9096
>

extensions/plugin-basic-ui/src/components/AppBar.css.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ export const container = style([
200200
}),
201201
selectors: {
202202
[`${android} &`]: {
203-
padding: "0 1rem",
203+
paddingLeft: globalVars.appBar.containerPadding,
204+
paddingRight: globalVars.appBar.containerPadding,
204205
},
205206
},
206207
},
@@ -211,16 +212,13 @@ export const left = style([
211212
f.fullHeight,
212213
appBarMinHeight,
213214
{
215+
paddingRight: globalVars.appBar.itemGap,
214216
":empty": {
215217
display: "none",
216218
},
217219
selectors: {
218-
[`${android} &`]: {
219-
paddingRight: "1rem",
220-
},
221220
[`${cupertino} &`]: {
222-
paddingLeft: "1rem",
223-
paddingRight: "1rem",
221+
paddingLeft: globalVars.appBar.containerPadding,
224222
},
225223
},
226224
},
@@ -237,8 +235,8 @@ export const backButton = style([
237235
opacity: "300ms",
238236
color: globalVars.appBar.iconColorTransitionDuration,
239237
}),
240-
padding: ".5rem",
241-
margin: "-.5rem",
238+
padding: globalVars.appBar.hitSlop,
239+
margin: `calc(-1 * ${globalVars.appBar.hitSlop})`,
242240
":active": {
243241
opacity: "0.2",
244242
transition: transitions({
@@ -254,8 +252,11 @@ export const closeButton = style([backButton]);
254252
export const center = style([f.flexAlignCenter, f.flex1, appBarMinHeight]);
255253

256254
export const centerMain = style({
257-
width: vars.appBar.center.mainWidth,
255+
display: "flex",
258256
color: globalVars.appBar.textColor,
257+
fontSize: globalVars.appBar.fontSize,
258+
lineHeight: globalVars.appBar.lineHeight,
259+
fontWeight: "bold",
259260
transition: transitions({
260261
height: globalVars.appBar.heightTransitionDuration,
261262
color: globalVars.appBar.textColorTransitionDuration,
@@ -264,20 +265,15 @@ export const centerMain = style({
264265
[`${android} &`]: {
265266
width: "100%",
266267
justifyContent: "flex-start",
267-
fontSize: "1.125rem",
268-
lineHeight: "1.5",
269-
fontWeight: "bold",
270268
boxSizing: "border-box",
271269
},
272270
[`${cupertino} &`]: {
271+
width: vars.appBar.center.mainWidth,
273272
position: "absolute",
274-
display: "flex",
275273
alignItems: "center",
276274
justifyContent: "center",
277275
textAlign: "center",
278276
fontFamily: "-apple-system, BlinkMacSystemFont",
279-
fontWeight: "bold",
280-
fontSize: "1.125rem",
281277
left: "50%",
282278
transform: "translate(-50%)",
283279
height: globalVars.appBar.height,
@@ -296,9 +292,9 @@ export const centerMainEdge = style([
296292
f.cursorPointer,
297293
{
298294
left: "50%",
299-
height: "1.25rem",
295+
height: globalVars.appBar.fontSize,
300296
transform: "translate(-50%)",
301-
maxWidth: "5rem",
297+
maxWidth: `calc(${globalVars.appBar.fontSize} * 5)`,
302298
display: "none",
303299
width: vars.appBar.center.mainWidth,
304300
selectors: {
@@ -326,17 +322,13 @@ export const right = style([
326322
f.posRel,
327323
appBarMinHeight,
328324
{
329-
marginLeft: "auto",
325+
paddingLeft: globalVars.appBar.itemGap,
330326
":empty": {
331327
display: "none",
332328
},
333329
selectors: {
334-
[`${android} &`]: {
335-
paddingLeft: "1rem",
336-
},
337330
[`${cupertino} &`]: {
338-
paddingLeft: "1rem",
339-
paddingRight: "1rem",
331+
paddingRight: globalVars.appBar.containerPadding,
340332
},
341333
},
342334
},

extensions/plugin-basic-ui/src/components/AppBar.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export type AppBarProps = Partial<
3333
| "backgroundColorTransitionDuration"
3434
| "backgroundImage"
3535
| "backgroundImageTransitionDuration"
36+
| "minHeight"
37+
| "fontSize"
38+
| "lineHeight"
39+
| "hitSlop"
40+
| "containerPadding"
41+
| "itemGap"
3642
>
3743
> & {
3844
title?: React.ReactNode;
@@ -93,6 +99,12 @@ const AppBar = forwardRef<HTMLDivElement, AppBarProps>(
9399
onTopClick,
94100
enterStyle,
95101
className,
102+
minHeight,
103+
fontSize,
104+
lineHeight,
105+
hitSlop,
106+
containerPadding,
107+
itemGap,
96108
},
97109
ref,
98110
) => {
@@ -323,6 +335,12 @@ const AppBar = forwardRef<HTMLDivElement, AppBarProps>(
323335
[globalVars.appBar.backgroundImageTransitionDuration]:
324336
backgroundImageTransitionDuration,
325337
[appScreenCss.vars.appBar.center.mainWidth]: `${maxWidth}px`,
338+
[globalVars.appBar.minHeight]: minHeight,
339+
[globalVars.appBar.containerPadding]: containerPadding,
340+
[globalVars.appBar.fontSize]: fontSize,
341+
[globalVars.appBar.hitSlop]: hitSlop,
342+
[globalVars.appBar.lineHeight]: lineHeight,
343+
[globalVars.appBar.itemGap]: itemGap,
326344
}),
327345
)}
328346
data-part="appBar"

0 commit comments

Comments
 (0)