Skip to content

frankdiw/poster

Repository files navigation

poster

poster是基于 jsx 搭建,使用 node-canvas 绘制的海报生成库

使用方式

通过 jsx 进行编辑,采用行内样式进行布局,支持 flex 布局。可以给 jsx 传入 props.

样式支持情况

Property Property Expanded Supported Values
display none and flex, default to flex
position relative and absolute, default to{' '} relative
color Supported
margin
marginTop Supported
marginRight Supported
marginBottom Supported
marginLeft Supported
Position
top Supported
right Supported
bottom Supported
left Supported
Size
width Supported
height Supported
Min & max size
minWidth Supported except for min-content, max-content and{' '} fit-content
minHeight Supported except for min-content, max-content and{' '} fit-content
maxWidth Supported except for min-content, max-content and{' '} fit-content
maxHeight Supported except for min-content, max-content and{' '} fit-content
border
Width (borderWidth, borderTopWidth, ...) Supported
Style (borderStyle, borderTopStyle, ...) solid and dashed, default to solid
Color (borderColor, borderTopColor, ...) Supported
Shorthand (border, borderTop, ...) Supported, i.e. 1px solid #000
borderRadius
borderTopLeftRadius Supported
borderTopRightRadius Supported
borderBottomLeftRadius Supported
borderBottomRightRadius Supported
Shorthand Supported, i.e. 5px
Flex
flexDirection column, row, row-reverse,{' '} column-reverse, default to row
flexWrap wrap, nowrap, wrap-reverse, default to wrap
flexGrow Supported
flexShrink Supported
flexBasis Supported except for auto
alignItems stretch, center, flex-start,{' '} flex-end, baseline, normal, default to stretch
alignContent Supported
alignSelf Supported
justifyContent Supported
gap Supported
Font
fontSize Supported
fontWeight Supported
fontStyle Supported
Text
textAlign left, right, center,, default to{' '} left
textOverflow clip, ellipsis, defaults to clip
textShadow Supported
lineHeight Supported
letterSpacing Supported
Background Support colorlinear-gradienturl
color Support rgba16进制hsla
opacity Supported
boxShadow Supported
lineClamp Supported

海报服务接口使用方式

import poster from '@frankdiw/poster';
export async function POST(request: NextRequest) {
  const data = await request.json();
  const base64 = await poster({ ...data, returnType: 'base64' });
  return Response.json({
    url: base64
  });
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published