本文整理匯總了TypeScript中@library/styles/styleUtils.useThemeCache函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript useThemeCache函數的具體用法?TypeScript useThemeCache怎麽用?TypeScript useThemeCache使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了useThemeCache函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: useThemeCache
export const richEditorClasses = useThemeCache((legacyMode: boolean, mobile?: boolean) => {
const globalVars = globalVariables();
const style = styleFactory("richEditor");
const vars = richEditorVariables();
const formVars = formElementsVariables();
const root = style({
position: "relative",
display: "block",
$nest: {
"&.isDisabled": {
$nest: {
"&, &.richEditor-button": {
cursor: important("progress"),
},
},
},
"& .richEditor-text, & .richEditor-textWrap, & .richEditor-frame": {
display: "flex",
flexDirection: "column",
flexGrow: 1,
position: "relative",
},
"& .ql-clipboard": {
...srOnly(),
position: "fixed", // Fixed https://github.com/quilljs/quill/issues/1374#issuecomment-415333651
},
"& .richEditor-nextInput, .iconButton, .richEditor-button": {
...singleLineEllipsis(),
...appearance(),
position: "relative",
border: 0,
padding: 0,
background: "none",
textAlign: "left",
},
"& .Close-x": {
display: "block",
cursor: "pointer",
},
"& .content-wrapper": {
height: percent(100),
},
"& .embedDialogue": {
position: "relative",
},
},
});
const iconWrap = style("iconWrap", {
...pointerEvents(),
content: quote(``),
...absolutePosition.middleOfParent(),
width: unit(vars.iconWrap.width),
height: unit(vars.iconWrap.height),
...borders({
radius: 3,
color: "transparent",
}),
});
const paragraphMenu = style("paragraphMenu", {
position: "absolute",
display: "flex",
alignItems: "center",
justifyContent: "center",
top: unit(vars.pilcrow.offset),
left: 0,
marginLeft: unit(-globalVars.gutter.quarter + (!legacyMode ? -(globalVars.gutter.size + 6) : 0)),
transform: `translateX(-100%)`,
height: unit(vars.paragraphMenuHandle.size),
width: unit(globalVars.icon.sizes.default),
animationName: vars.pilcrow.animation.name,
animationDuration: vars.pilcrow.animation.duration,
animationTimingFunction: vars.pilcrow.animation.timing,
animationIterationCount: vars.pilcrow.animation.iterationCount,
zIndex: 1,
$nest: {
".richEditor-button&.isActive:hover": {
cursor: "default",
},
"&.isMenuInset": {
transform: "none",
},
},
});
const paragraphMenuMobile = style("paragraphMenu-mobile", {
position: "relative",
display: "flex",
alignItems: "center",
justifyContent: "center",
top: important(0),
});
const menuBar = style("menuBar", {
position: "relative",
width: unit(vars.menuButton.size * 4),
overflow: "hidden",
});
//.........這裏部分代碼省略.........
示例2: useThemeCache
* @license GPL-2.0-only
*/
import { absolutePosition, flexHelper, unit, sticky, colorOut } from "@library/styles/styleHelpers";
import { globalVariables } from "@library/styles/globalStyleVars";
import {styleFactory, useThemeCache, variableFactory} from "@library/styles/styleUtils";
import { calc, percent, viewHeight } from "csx";
export const compactMeBoxVariables = useThemeCache(() => {
const themeVars = variableFactory("compactMeBox");
const globalVars = globalVariables();
const tab = themeVars("tab", {
height: 44,
width: 44,
});
const colors = themeVars("colors", {
bg: globalVars.mainColors.bg,
});
return { tab, colors };
});
export const compactMeBoxClasses = useThemeCache(() => {
const globalVars = globalVariables();
const vars = compactMeBoxVariables();
const style = styleFactory("compactMeBox");
const root = style({
display: "block",
示例3: useThemeCache
/*
* @author Stéphane LaFlèche <stephane.l@vanillaforums.com>
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
*/
import { unit } from "@library/styles/styleHelpers";
import { styleFactory, useThemeCache } from "@library/styles/styleUtils";
import { percent } from "csx";
import { containerVariables } from "@library/layout/components/containerStyles";
export const widgetContainerClasses = useThemeCache(() => {
const style = styleFactory("widgetContainerClasses");
const vars = containerVariables();
const root = style({
position: "relative",
maxWidth: percent(100),
margin: "auto",
width: unit(vars.sizing.narrowContentSize),
});
return {
root,
};
});
示例4: useThemeCache
/*
* @author Stéphane LaFlèche <stephane.l@vanillaforums.com>
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
*/
import { globalVariables } from "@library/styles/globalStyleVars";
import { unit } from "@library/styles/styleHelpers";
import { useThemeCache, styleFactory } from "@library/styles/styleUtils";
export const emojiGroupsClasses = useThemeCache(() => {
const globalVars = globalVariables();
const style = styleFactory("emojiGroups");
const root = style({
display: "flex",
flexWrap: "nowrap",
justifyContent: "center",
});
const icon = style("icon", {
display: "block",
position: "relative",
margin: "auto",
padding: 0,
width: unit(globalVars.icon.sizes.default),
height: unit(globalVars.icon.sizes.default),
});
return { root, icon };
});
示例5: useThemeCache
export const navLinksVariables = useThemeCache(() => {
const makeThemeVars = variableFactory("navLinks");
const globalVars = globalVariables();
const linksWithHeadings = makeThemeVars("linksWithHeadings", {
paddings: {
all: 20,
},
mobile: {
paddings: {
all: 0,
},
},
});
const item = makeThemeVars("item", {
fontSize: globalVars.fonts.size.large,
});
const title = makeThemeVars("title", {
fontSize: globalVars.fonts.size.smallTitle,
fontWeight: globalVars.fonts.weights.semiBold,
lineHeight: globalVars.lineHeights.condensed,
maxWidth: percent(100),
margins: {
bottom: 8,
},
mobile: {
fontSize: globalVars.fonts.size.large,
fontWeight: globalVars.fonts.weights.bold,
},
});
const link = makeThemeVars("link", {
fg: globalVars.mainColors.fg,
fontWeight: globalVars.fonts.weights.semiBold,
lineHeight: globalVars.lineHeights.condensed,
width: 203,
maxWidth: percent(100),
fontSize: 16,
});
const viewAllLinkColors = setAllLinkColors();
const viewAll = makeThemeVars("viewAll", {
color: viewAllLinkColors.color,
fontWeight: globalVars.fonts.weights.semiBold,
fontSize: globalVars.fonts.size.medium,
margins: {
top: "auto",
},
paddings: {
top: 20,
},
mobile: {
paddings: {
top: 8,
},
},
$nest: viewAllLinkColors.nested,
});
const spacing = makeThemeVars("spacing", {
paddings: {
vertical: 34,
horizontal: 40,
},
margin: 6,
mobile: {
paddings: {
vertical: 22,
horizontal: 8,
},
},
});
const columns = makeThemeVars("columns", {
desktop: 2,
});
const separator = makeThemeVars("separator", {
height: 1,
bg: globalVars.mixBgAndFg(0.3),
});
const breakPoints = makeThemeVars("breakPoints", {
oneColumn: 750,
});
const mediaQueries = () => {
const oneColumn = styles => {
return media({ maxWidth: px(breakPoints.oneColumn) }, styles);
};
return { oneColumn };
};
return {
linksWithHeadings,
item,
title,
//.........這裏部分代碼省略.........
示例6: 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",
});
});
示例7: useThemeCache
export const siteNavVariables = useThemeCache(() => {
const globalVars = globalVariables();
const makeThemeVars = variableFactory("siteNav");
const node = makeThemeVars("node", {
fontSize: globalVars.fonts.size.medium,
fg: globalVars.mainColors.fg,
lineHeight: globalVars.lineHeights.condensed,
borderWidth: 1,
padding: 4,
active: {
fg: globalVars.links.colors.default,
fontWeight: globalVars.fonts.weights.bold,
},
});
const title = makeThemeVars("title", {
fontSize: globalVars.fonts.size.large,
fontWeight: globalVars.fonts.weights.bold,
});
const nodeToggle = makeThemeVars("nodeToggle", {
height: node.fontSize * node.lineHeight,
width: globalVars.gutter.size,
iconWidth: 7,
});
const spacer = makeThemeVars("spacer", {
default: 7,
});
return { node, title, nodeToggle, spacer };
});
示例8: useThemeCache
export const frameVariables = useThemeCache(() => {
const globalVars = globalVariables();
const makeThemeVars = variableFactory("frame");
const colors = makeThemeVars("colors", {
bg: globalVars.mainColors.bg,
fg: globalVars.mainColors.fg,
});
const sizing = makeThemeVars("sizing", {
large: 720,
medium: 516,
small: 375,
});
const border = makeThemeVars("border", {
radius: globalVars.border.radius,
});
const spacing = makeThemeVars("spacing", {
padding: 16,
});
const header = makeThemeVars("header", {
spacing: spacing.padding,
minHeight: 44,
fontSize: globalVars.fonts.size.subTitle,
});
const footer = makeThemeVars("footer", {
spacing: spacing.padding,
minHeight: header.minHeight,
});
return {
colors,
sizing,
border,
spacing,
header,
footer,
};
});
示例9: useThemeCache
export const layoutVariables = useThemeCache(() => {
const makeThemeVars = variableFactory("globalVariables");
// Important variables that will be used to calculate other variables
const foundationalWidths = makeThemeVars("foundationalWidths", {
fullGutter: 48,
panelWidth: 216,
middleColumnWidth: 672,
minimalMiddleColumnWidth: 500, // Will break if middle column width is smaller than this value.
narrowContentWidth: 900, // For home page widgets, narrower than full width
breakPoints: {
// Other break points are calculated
twoColumns: 1200,
xs: 500,
},
});
const gutter = makeThemeVars("gutter", {
full: foundationalWidths.fullGutter, // 48
size: foundationalWidths.fullGutter / 2, // 24
halfSize: foundationalWidths.fullGutter / 4, // 12
quarterSize: foundationalWidths.fullGutter / 8, // 6
});
const panel = makeThemeVars("panel", {
width: foundationalWidths.panelWidth,
paddedWidth: foundationalWidths.panelWidth + gutter.full,
});
const middleColumn = makeThemeVars("middleColumn", {
width: foundationalWidths.middleColumnWidth,
paddedWidth: foundationalWidths.middleColumnWidth + gutter.full,
});
const globalContentWidth = middleColumn.paddedWidth + panel.paddedWidth * 2 + gutter.size;
const contentSizes = makeThemeVars("content", {
full: globalContentWidth,
narrow:
foundationalWidths.narrowContentWidth < globalContentWidth
? foundationalWidths.narrowContentWidth
: globalContentWidth,
});
const panelLayoutBreakPoints = makeThemeVars("panelLayoutBreakPoints", {
noBleed: globalContentWidth,
twoColumn: foundationalWidths.breakPoints.twoColumns,
oneColumn: foundationalWidths.minimalMiddleColumnWidth + panel.paddedWidth,
xs: foundationalWidths.breakPoints.xs,
});
const panelLayoutSpacing = makeThemeVars("panelLayoutSpacing", {
margin: {
top: 0,
bottom: 50,
},
padding: {
top: gutter.halfSize * 1.5,
},
extraPadding: {
top: 32,
noBreadcrumbs: {
top: 16,
},
},
largePadding: {
top: 64,
},
});
const mediaQueries = () => {
const noBleed = styles => {
return media(
{
maxWidth: px(panelLayoutBreakPoints.noBleed),
minWidth: px(panelLayoutBreakPoints.twoColumn + 1),
},
styles,
);
};
const noBleedDown = styles => {
return media(
{
maxWidth: px(panelLayoutBreakPoints.noBleed),
},
styles,
);
};
const twoColumnsDown = styles => {
return media(
{
maxWidth: px(panelLayoutBreakPoints.twoColumn),
},
styles,
);
};
const twoColumns = styles => {
//.........這裏部分代碼省略.........
示例10: useThemeCache
export const userDropDownVariables = useThemeCache(() => {
const globalVars = globalVariables();
const themeVars = componentThemeVariables("userDropDown");
const item = {
topPadding: 6,
rightPadding: 18,
bottomPadding: 6,
leftPadding: 18,
...themeVars.subComponentStyles("item"),
};
const userCard = {
topMargin: 24,
bottomMargin: 24,
...themeVars.subComponentStyles("userCard"),
};
const userName = {
topMargin: 9,
bottomMargin: 24,
paddingRight: item.rightPadding,
paddingLeft: item.leftPadding,
fontWeight: globalVars.fonts.weights.semiBold,
fontSize: globalVars.fonts.size.large,
lineHeight: globalVars.lineHeights.condensed,
...themeVars.subComponentStyles("userName"),
};
const contents = {
width: 300,
...themeVars.subComponentStyles("contents"),
};
return { userCard, userName, contents, item };
});