本文整理汇总了TypeScript中@library/styles/styleHelpers.margins函数的典型用法代码示例。如果您正苦于以下问题:TypeScript margins函数的具体用法?TypeScript margins怎么用?TypeScript margins使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了margins函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: useThemeCache
export const bodyCSS = useThemeCache(() => {
const globalVars = globalVariables();
cssRule("html, body", {
backgroundColor: colorOut(globalVars.body.backgroundImage.color),
...fonts({
size: globalVars.fonts.size.medium,
family: globalVars.fonts.families.body,
color: globalVars.mainColors.fg,
}),
wordBreak: "break-word",
overscrollBehavior: "none", // For IE -> https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior
});
cssRule("*", {
// For Mobile Safari -> https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior
"-webkit-overflow-scrolling": "touch",
});
cssRule("h1, h2, h3, h4, h5, h6", {
display: "block",
lineHeight: globalVars.lineHeights.condensed,
...margins({
all: 0,
}),
...paddings({
all: 0,
}),
});
cssRule("p", {
...margins({
all: 0,
}),
...paddings({
all: 0,
}),
});
cssRule(".page", {
display: "flex",
overflow: "visible",
flexDirection: "column",
width: percent(100),
minHeight: viewHeight(100),
position: "relative",
zIndex: 0,
});
cssRule(".page-minHeight", {
flexGrow: 1,
display: "flex",
flexDirection: "column",
});
});
示例2: useThemeCache
export const attachmentIconsClasses = useThemeCache(() => {
const globalVars = globalVariables();
const vars = attachmentIconVariables();
const style = styleFactory("attachmentIcons");
const root = style({
display: "block",
position: "relative",
});
const items = style("items", {
display: "flex",
flexWrap: "wrap",
alignItems: "flex-start",
justifyContent: "flex-end",
width: calc(`100% + ${px(vars.spacing.default * 2)}`),
overflow: "hidden",
...margins({
top: -vars.spacing.default,
left: -vars.spacing.default,
right: globalVars.meta.spacing.default,
}),
});
const item = style("item", {
margin: vars.spacing.default,
});
return { root, items, item };
});
示例3: useThemeCache
export const navLinksClasses = useThemeCache(() => {
const globalVars = globalVariables();
const vars = navLinksVariables();
const style = styleFactory("navLinks");
const mediaQueries = vars.mediaQueries();
const root = style(
{
...paddings(vars.spacing.paddings),
display: "flex",
flexDirection: "column",
maxWidth: percent(100),
width: percent(100 / vars.columns.desktop),
},
mediaQueries.oneColumn({
width: percent(100),
...paddings(vars.spacing.mobile.paddings),
}),
);
const items = style("items", {
display: "flex",
flexDirection: "column",
flexGrow: 1,
});
const item = style("item", {
display: "block",
fontSize: unit(vars.item.fontSize),
marginTop: unit(vars.spacing.margin),
marginBottom: unit(vars.spacing.margin),
});
const title = style(
"title",
{
display: "block",
fontSize: unit(vars.title.fontSize),
lineHeight: globalVars.lineHeights.condensed,
fontWeight: globalVars.fonts.weights.semiBold,
maxWidth: percent(100),
...margins(vars.title.margins),
},
mediaQueries.oneColumn({
fontSize: unit(vars.title.mobile.fontSize),
fontWeight: vars.title.mobile.fontWeight,
}),
);
const linkColors = setAllLinkColors({
default: globalVars.mainColors.fg,
});
const link = style("link", {
display: "block",
fontSize: unit(vars.link.fontSize),
lineHeight: vars.link.lineHeight,
color: linkColors.color,
$nest: linkColors.nested,
});
const viewAllitem = style(
"viewAllItem",
{
display: "block",
fontSize: unit(vars.item.fontSize),
...margins(vars.viewAll.margins),
...paddings(vars.viewAll.paddings),
},
mediaQueries.oneColumn({
...paddings(vars.viewAll.mobile.paddings),
}),
);
const viewAllLinkColors = setAllLinkColors({
default: globalVars.mainColors.primary,
});
const viewAll = style("viewAll", {
display: "block",
fontWeight: vars.viewAll.fontWeight,
fontSize: vars.viewAll.fontSize,
color: viewAllLinkColors.color,
$nest: viewAllLinkColors.nested,
});
const linksWithHeadings = style(
"linksWithHeadings",
{
...paddings(vars.linksWithHeadings.paddings),
display: "flex",
flexWrap: "wrap",
alignItems: "stretch",
justifyContent: "space-between",
},
mediaQueries.oneColumn({
...paddings(vars.linksWithHeadings.mobile.paddings),
}),
);
//.........这里部分代码省略.........
示例4: useThemeCache
export const metasClasses = useThemeCache(() => {
const vars = metasVariables();
const globalVars = globalVariables();
const style = styleFactory("frame");
const root = style({
display: "block",
lineHeight: globalVars.lineHeights.meta,
color: colorOut(vars.colors.fg),
width: calc(`100% + ${vars.spacing.default * 2}`),
overflow: "hidden",
textAlign: "left",
...margins({
left: -vars.spacing.default,
right: vars.spacing.default,
}),
$nest: {
a: {
...allLinkStates({
allStates: {
textShadow: "none",
},
noState: {
color: colorOut(vars.colors.fg),
},
hover: {
color: colorOut(vars.colors.hover.fg),
},
focus: {
color: colorOut(vars.colors.focus.fg),
},
active: {
color: colorOut(vars.colors.active.fg),
},
}),
},
"&.isFlexed": {
display: "flex",
flexWrap: "wrap",
justifyContent: "flex-start",
alignItems: "center",
},
},
});
const meta = style("meta", {
display: "inline-block",
fontSize: unit(vars.fonts.size),
color: colorOut(vars.colors.fg),
...margins({
top: 0,
right: vars.spacing.default,
bottom: 0,
left: vars.spacing.default,
}),
$nest: {
"& &": {
margin: 0,
},
},
});
// Get styles of meta, without the margins
const metaStyle = style("metaStyles", {
display: "inline-block",
fontSize: unit(vars.fonts.size),
color: colorOut(vars.colors.fg),
});
const draftStatus = style("draftStatus", {
flexGrow: 1,
textAlign: "left",
});
return {
root,
meta,
metaStyle,
draftStatus,
};
});
示例5: useThemeCache
//.........这里部分代码省略.........
color: vars.separator.fg,
width: vars.separator.width,
}) as any,
$nest: {
[`&:hover .${title}`]: {
color: colorOut(vars.colors.hover.fg),
},
[`&:focus .${title}`]: {
color: colorOut(vars.colors.hover.fg),
},
[`&:active .${title}`]: {
color: colorOut(vars.colors.hover.fg),
},
"&:not(.focus-visible)": {
outline: 0,
},
},
},
mediaQueries.compact({
flexWrap: "wrap",
}),
);
const main = style(
"main",
{
display: "block",
width: percent(100),
$nest: {
"&.hasMedia": {
width: calc(`100% - ${unit(vars.mediaElement.width + vars.spacing.padding.left)}`),
},
},
},
mediaQueries.compact({
$nest: {
"&.hasMedia": {
width: percent(100),
},
},
}),
);
const mediaElement = style(
"mediaElement",
{
position: "relative",
width: unit(vars.mediaElement.width),
},
mediaQueries.compact({
width: percent(100),
$nest: {
"&.hasImage": {
height: unit(vars.mediaElement.width),
},
},
}),
);
const image = style("image", {
...objectFitWithFallback(),
});
const attachments = style(
"attachments",
{
display: "flex",
flexWrap: "nowrap",
},
mediaQueries.compact({
flexWrap: "wrap",
width: percent(100),
marginTop: unit(12),
}),
);
const metas = style("metas", {
marginTop: unit(4),
...margins({
left: -metaVars.spacing.default,
}),
width: calc(`100% + ${unit(metaVars.spacing.default * 2)}`),
});
const excerpt = style("excerpt", {
marginTop: unit(12),
color: colorOut(vars.excerpt.fg),
});
return {
root,
main,
mediaElement,
image,
title,
attachments,
metas,
excerpt,
};
});
示例6: useThemeCache
export const panelLayoutClasses = useThemeCache(() => {
const globalVars = globalVariables();
const vars = layoutVariables();
const mediaQueries = vars.mediaQueries();
const style = styleFactory("panelLayout");
const classesPanelArea = panelAreaClasses();
const classesPanelList = panelListClasses();
const titleBarVars = titleBarVariables();
const main = style("main", {
minHeight: viewHeight(20),
width: percent(100),
});
const root = style({
...margins(vars.panelLayoutSpacing.margin),
width: percent(100),
$nest: {
[`&.noBreadcrumbs > .${main}`]: {
paddingTop: unit(globalVars.gutter.size),
...mediaQueries.oneColumnDown({
paddingTop: 0,
}),
},
"&.isOneCol": {
width: unit(vars.middleColumn.paddedWidth),
maxWidth: percent(100),
margin: "auto",
...mediaQueries.oneColumnDown({
width: percent(100),
}),
},
"&.hasTopPadding": {
paddingTop: unit(vars.panelLayoutSpacing.extraPadding.top),
},
"&.hasTopPadding.noBreadcrumbs": {
paddingTop: unit(vars.panelLayoutSpacing.extraPadding.noBreadcrumbs.top),
},
"&.hasLargePadding": {
...paddings(vars.panelLayoutSpacing.largePadding),
},
},
});
const content = style("content", {
display: "flex",
flexGrow: 1,
width: percent(100),
justifyContent: "space-between",
});
const panel = style("panel", {
width: percent(100),
$nest: {
[`& > .${classesPanelArea.root}:first-child .${classesPanelList.root}`]: {
marginTop: unit(
(globalVars.fonts.size.title * globalVars.lineHeights.condensed) / 2 -
globalVariables().fonts.size.medium / 2,
),
},
},
});
const top = style("top", {
width: percent(100),
marginBottom: unit(globalVars.gutter.half),
});
const container = style("container", {
display: "flex",
flexWrap: "nowrap",
alignItems: "flex-start",
justifyContent: "space-between",
});
const fullWidth = style("fullWidth", {
position: "relative",
padding: 0,
});
const leftColumn = style("leftColumn", {
position: "relative",
width: unit(vars.panel.paddedWidth),
flexBasis: unit(vars.panel.paddedWidth),
minWidth: unit(vars.panel.paddedWidth),
});
const rightColumn = style("rightColumn", {
position: "relative",
width: unit(vars.panel.paddedWidth),
flexBasis: unit(vars.panel.paddedWidth),
minWidth: unit(vars.panel.paddedWidth),
overflow: "initial",
});
const middleColumn = style("middleColumn", {
justifyContent: "space-between",
flexGrow: 1,
width: percent(100),
maxWidth: percent(100),
//.........这里部分代码省略.........
示例7: useThemeCache
//.........这里部分代码省略.........
...buttonStates({
allStates: {
textShadow: "none",
outline: 0,
},
hover: {
backgroundColor: colorOut(globalVars.states.hover.color),
},
focus: {
backgroundColor: colorOut(globalVars.states.focus.color),
},
active: {
backgroundColor: colorOut(globalVars.states.active.color),
},
accessibleFocus: {
borderColor: colorOut(globalVars.mainColors.primary),
},
}),
},
mediaQueries.oneColumnDown({
fontSize: unit(vars.item.mobile.fontSize),
fontWeight: globalVars.fonts.weights.semiBold,
minHeight: unit(vars.item.mobile.minHeight),
}),
);
const text = style("text", {
display: "block",
});
const separator = style("separator", {
height: unit(globalVars.separator.size),
backgroundColor: colorOut(globalVars.separator.color),
...margins(vars.spacer.margin),
});
const sectionHeading = style("sectionHeading", {
color: colorOut(globalVars.meta.text.color),
fontSize: unit(globalVars.fonts.size.small),
textTransform: "uppercase",
textAlign: "center",
fontWeight: globalVars.fonts.weights.semiBold,
...(paddings(vars.sectionTitle.padding) as NestedCSSProperties),
});
const sectionContents = style("sectionContents", {
display: "block",
});
const count = style("count", {
fontSize: unit(globalVars.fonts.size.small),
paddingLeft: "1em",
marginLeft: "auto",
});
const verticalPadding = style(
"verticalPadding",
{
...paddings({
vertical: vars.contents.padding.vertical,
horizontal: 0,
}),
},
mediaQueries.oneColumnDown({
...paddings({
vertical: 0,
示例8: useThemeCache
export const modalClasses = useThemeCache(() => {
const globalVars = globalVariables();
const vars = modalVariables();
const style = styleFactory("modal");
const mediaQueries = layoutVariables().mediaQueries();
const shadows = shadowHelper();
const titleBarVars = titleBarVariables();
const overlay = style("overlay", {
position: "fixed",
// Viewport units are useful here because
// we're actually fine this being taller than the initially visible viewport.
height: viewHeight(100),
width: percent(100),
top: 0,
left: 0,
right: 0,
bottom: 0,
background: colorOut(vars.colors.overlayBg),
zIndex: 10,
});
const root = style({
display: "flex",
flexDirection: "column",
width: percent(100),
maxWidth: percent(100),
maxHeight: viewHeight(80),
zIndex: 1,
backgroundColor: colorOut(vars.colors.bg),
position: "fixed",
top: percent(50),
left: percent(50),
bottom: "initial",
overflow: "hidden",
borderRadius: unit(vars.border.radius),
// NOTE: This transform can cause issues if anything inside of us needs fixed positioning.
// See http://meyerweb.com/eric/thoughts/2011/09/12/un-fixing-fixed-elements-with-css-transforms/
// See also https://www.w3.org/TR/2009/WD-css3-2d-transforms-20091201/#introduction
// This is why fullscreen unsets the transforms.
transform: translate(`-50%`, `-50%`),
...margins({ all: "auto" }),
$nest: {
"&&.isFullScreen": {
width: percent(100),
height: percent(100),
maxHeight: percent(100),
maxWidth: percent(100),
borderRadius: 0,
border: "none",
top: 0,
bottom: 0,
transform: "none",
left: 0,
right: 0,
},
"&.isLarge": {
width: unit(vars.sizing.large),
maxWidth: calc(`100% - ${unit(vars.spacing.horizontalMargin * 2)}`),
},
"&.isMedium": {
width: unit(vars.sizing.medium),
maxWidth: calc(`100% - ${unit(vars.spacing.horizontalMargin * 2)}`),
},
"&.isSmall": {
width: unit(vars.sizing.small),
maxWidth: calc(`100% - ${unit(vars.spacing.horizontalMargin * 2)}`),
},
"&&&.isSidePanel": {
left: unit(vars.dropDown.padding),
width: calc(`100% - ${unit(vars.dropDown.padding)}`),
display: "flex",
flexDirection: "column",
top: 0,
bottom: 0,
right: 0,
transform: "none",
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
"&&.isDropDown": {
top: 0,
left: 0,
right: 0,
bottom: globalVars.gutter.size,
width: percent(100),
marginBottom: "auto",
transform: "none",
maxHeight: percent(100),
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
},
"&.isShadowed": {
...shadows.dropDown(),
...borders(),
},
},
});
//.........这里部分代码省略.........
示例9: useThemeCache
export const userContentClasses = useThemeCache(() => {
const style = styleFactory("userContent");
const vars = userContentVariables();
const globalVars = globalVariables();
const listItem: NestedCSSProperties = {
position: "relative",
...margins({
top: vars.list.spacing.top,
left: vars.list.spacing.left,
}),
$nest: {
"&:first-child": {
marginTop: 0,
},
"&:last-child": {
marginBottom: 0,
},
},
};
const headingStyle = (tag: string, fontSize: FontSizeProperty<TLength>): NestedCSSProperties => {
return {
marginTop: globalVars.spacer.size,
fontSize,
$nest: lineHeightAdjustment(globalVars.lineHeights.condensed),
};
};
const headings: NestedCSSSelectors = {
"& h1": headingStyle("h1", vars.fonts.headings.h1),
"& h2": headingStyle("h2", vars.fonts.headings.h2),
"& h3": headingStyle("h3", vars.fonts.headings.h3),
"& h4": headingStyle("h4", vars.fonts.headings.h4),
"& h5": headingStyle("h5", vars.fonts.headings.h5),
"& h6": headingStyle("h6", vars.fonts.headings.h6),
};
const lists: NestedCSSSelectors = {
"& ol": {
listStylePosition: "inside",
},
"& ol li": {
...listItem,
listStyle: "decimal",
},
"& ul li": {
...listItem,
listStyle: "initial",
},
};
const paragraphSpacing: NestedCSSSelectors = {
"& p": {
marginTop: 0,
marginBottom: 0,
$nest: {
"&:not(:first-child)": {
marginTop: vars.blocks.margin * 0.5,
},
"&:first-child": {
$nest: lineHeightAdjustment(globalVars.lineHeights.base),
},
},
},
"&& > *:not(:last-child)": {
marginBottom: vars.blocks.margin,
},
"&& > *:first-child": {
marginTop: 0,
},
};
const linkColors = setAllLinkColors();
const linkStyle = {
color: linkColors.color,
$nest: {
...linkColors.nested,
"&:hover, &:focus": {
textDecoration: "underline",
},
},
};
const linkStyles: NestedCSSSelectors = {
a: linkStyle,
"p a": linkStyle,
"li a": linkStyle,
};
const codeStyles: NestedCSSSelectors = {
"& .code": {
position: "relative",
fontSize: vars.code.fontSize,
fontFamily: `Menlo, Monaco, Consolas, "Courier New", monospace`,
maxWidth: percent(100),
overflowX: "auto",
margin: 0,
color: colorOut(vars.code.fg),
//.........这里部分代码省略.........
示例10: useThemeCache
export const messagesClasses = useThemeCache(() => {
const vars = messagesVariables();
const globalVars = globalVariables();
const style = styleFactory("messages");
const titleBarVars = titleBarVariables();
const shadows = shadowHelper();
const mediaQueries = layoutVariables().mediaQueries();
// Fixed wrapper
const fixed = style("fixed", {
position: "fixed",
left: 0,
top: unit(titleBarVars.sizing.height - 8),
minHeight: unit(vars.sizing.minHeight),
width: percent(100),
maxWidth: viewWidth(100),
zIndex: 20,
});
const root = style(
{
width: percent(100),
},
margins({ horizontal: "auto" }),
);
const wrap = style(
"wrap",
{
display: "flex",
alignItems: "center",
justifyContent: "flex-start",
minHeight: unit(vars.sizing.minHeight),
backgroundColor: colorOut(vars.colors.bg),
width: percent(100),
...shadowOrBorderBasedOnLightness(
globalVars.body.backgroundImage.color,
borders({
color: globalVars.mainColors.fg,
}),
shadows.embed(),
),
margin: "auto",
color: colorOut(vars.colors.fg),
...paddings({
...vars.spacing.padding,
right: vars.spacing.padding.horizontal / 2,
}),
},
mediaQueries.xs({
flexWrap: "wrap",
paddingLeft: unit(vars.spacing.padding.horizontal / 2),
}),
);
const message = style("message", {
...userSelect(),
...fonts(vars.text.font),
flex: 1,
});
const setWidth = style("setWidth", {
width: unit(vars.sizing.width),
maxWidth: percent(100),
});
const actionButton = style(
"actionButton",
{
...paddings(vars.actionButton.padding),
minHeight: unit(vars.actionButton.minHeight),
whiteSpace: "nowrap",
...fonts(vars.actionButton.font),
...allButtonStates({
noState: {
color: colorOut(vars.colors.fg),
},
allStates: {
color: colorOut(vars.colors.states.fg),
},
focusNotKeyboard: {
outline: 0,
},
}),
},
mediaQueries.xs({
padding: 0,
width: percent(100),
textAlign: "center",
}),
);
return {
root,
wrap,
actionButton,
message,
fixed,
setWidth,
};
//.........这里部分代码省略.........