styled-components#ThemeContext JavaScript Examples
The following examples show how to use
styled-components#ThemeContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnbondingInitVol.jsx From cosmoscan-front with Apache License 2.0 | 6 votes |
UnbondingInitVol = () => {
const theme = useContext(ThemeContext);
const coin = useCoinFormatter();
const color = theme.danger;
const res = useRequest(API.getUndelegationVol, defaultPeriod.value);
const undelegationVolComp = useChartFormatter(res.resp);
const chartName = `Initiated unbonding per day/hour volume (${coin})`;
return (
<ChartContainer
title={chartName}
select={
<SelectPeriod
defaultPeriod={defaultPeriod}
isDisabled={res.isLoading}
onChange={res.request}
/>
}
chart={
<AreaChart
areaName={areaName}
isLoading={res.isLoading}
data={undelegationVolComp}
yAxisLabelsFormatter={formatTokenAmount}
yAxisWidth={yAxisWidth}
yTickCount={yTickCount}
yAxisDomain={[
(dataMin) => Math.round(dataMin),
(dataMax) => Math.round(dataMax),
]}
xAxisTickFormatter={formatDate}
tooltipFormatter={formatToken}
tooltipLabelFormatter={formatDateWithTime}
color={color}
/>
}
/>
);
}
Example #2
Source File: OrderRow.js From dexwebapp with Apache License 2.0 | 6 votes |
EmptyOrderRow = () => {
const theme = useContext(ThemeContext);
return (
<CompactOrderTableRow style={{ userSelect: 'none' }}>
<CompactOrderTablePriceColumn
style={{ color: theme.inputPlaceHolderColor }}
>
-
</CompactOrderTablePriceColumn>
<CompactOrderTableSizeColumn
style={{ color: theme.inputPlaceHolderColor }}
>
-
</CompactOrderTableSizeColumn>
<CompactOrderTablePositionColumn
style={{ color: theme.inputPlaceHolderColor }}
>
-
</CompactOrderTablePositionColumn>
</CompactOrderTableRow>
);
}
Example #3
Source File: EmptyTableIndicator.js From loopring-pay with Apache License 2.0 | 6 votes |
EmptyTableIndicator = ({ text, ...props }) => {
const theme = useContext(ThemeContext);
if (props.loading) {
return <div />;
}
return (
<EmptyTableIndicatorWrapper>
<img
style={{
marginTop: props.marginTop,
width: "68px",
height: "auto",
userSelect: "none",
opacity: "1",
}}
src={`assets/images/${theme.imgDir}/no-data.svg`}
alt="No Data"
draggable="false"
/>
<div
style={{
paddingTop: "2px",
fontSize: "0.85rem",
marginBottom: props.marginTop,
}}
>
<I s={text} />
</div>
</EmptyTableIndicatorWrapper>
);
}
Example #4
Source File: TradePanelWarnMessage.js From dexwebapp with Apache License 2.0 | 6 votes |
TradePanelWarnMessage = ({ show, message }) => {
return (
<div
style={{
display: show ? 'initial' : 'none',
fontSize: '0.85rem',
color: useContext(ThemeContext).orange,
height: '24px',
fontWeight: '600',
}}
>
<FontAwesomeIcon
style={{ marginRight: '8px' }}
size="1x"
icon={faExclamationTriangle}
/>
<I s={message} />
</div>
);
}
Example #5
Source File: Home.js From gitpedia with MIT License | 6 votes |
Home = () => {
const { id, setTheme } = useContext(ThemeContext);
return (
<>
<StyledHeader>
<Toggle isDark={id === 'dark'} onToggle={setTheme} />
</StyledHeader>
<Container>
<Logo width="280px" />
<Form displaySpan />
</Container>
</>
);
}
Example #6
Source File: NumOfDelegators.jsx From cosmoscan-front with Apache License 2.0 | 6 votes |
NumOfDelegators = () => {
const { address } = useParams();
const theme = useContext(ThemeContext);
const color = theme.navyBlue;
const { resp, isLoading } = useRequest(API.getNumOfDelegators, address);
const numOfDelegators = useChartFormatter(resp);
return (
<ChartContainer
title={chartName}
chart={
<AreaChart
areaName={areaName}
isLoading={isLoading}
data={numOfDelegators}
yAxisLabelsFormatter={formatLabels}
yAxisWidth={yAxisWidth}
yTickCount={yTickCount}
yAxisDomain={['dataMin', 'dataMax']}
xAxisTickFormatter={formatDate}
tooltipFormatter={formatNum}
tooltipLabelFormatter={formatDateWithTime}
color={color}
/>
}
/>
);
}
Example #7
Source File: TradePanelErrorMessage.js From dexwebapp with Apache License 2.0 | 6 votes |
TradePanelErrorMessage = ({
show,
errorMessage1,
errorToken,
errorMessage2,
}) => {
return (
<div
style={{
display: show ? 'initial' : 'none',
fontSize: '0.85rem',
color: useContext(ThemeContext).red,
height: '24px',
fontWeight: '600',
}}
>
<FontAwesomeIcon
style={{ marginRight: '8px' }}
size="1x"
icon={faExclamationTriangle}
/>
<I s={errorMessage1} />
{errorToken}
<I s={errorMessage2} />
</div>
);
}
Example #8
Source File: ThemeContext.js From VTour with MIT License | 6 votes |
ThemeContext.Extend = function (_ref) {
var children = _ref.children,
value = _ref.value;
return React.createElement(ThemeContext.Consumer, null, function (theme) {
return React.createElement(ThemeContext.Provider, {
value: deepMerge(theme, value)
}, children);
});
};
Example #9
Source File: OperationsPerBlock.jsx From cosmoscan-front with Apache License 2.0 | 6 votes |
OperationsPerBlock = () => {
const theme = useContext(ThemeContext);
const color = theme.danger;
return (
<Card>
<Card.Header>
<TitleChart>Operations per block</TitleChart>
</Card.Header>
<Card.Body>
<AreaChart
data={data}
yAxisWidth={yAxisWidth}
yTickCount={yTickCount}
areaName={areaName}
color={color}
/>
</Card.Body>
</Card>
);
}
Example #10
Source File: SecondaryNavBar.js From loopring-pay with Apache License 2.0 | 6 votes |
SecondaryNavBar = ({ selected, subPages }) => {
const theme = useContext(ThemeContext);
return (
<div
style={{
paddingLeft: "260px",
paddingRight: "60px",
paddingBottom: "0px",
borderWidth: "0px",
backgroundColor: theme.secondaryNavbarBackground,
}}
>
<Button.Group
style={{
borderRadius: "0px",
borderWidth: "0px",
paddingBottom: "0px",
}}
>
{subPages.map((config, i) => (
<NavButton
key={i}
selected={selected}
id={config.id}
href={config.url}
label={<I s={config.label} />}
/>
))}
</Button.Group>
</div>
);
}
Example #11
Source File: EmptyTableIndicator.js From dexwebapp with Apache License 2.0 | 6 votes |
EmptyTableIndicator = ({ text, ...props }) => {
const theme = useContext(ThemeContext);
if (props.loading) {
return <div />;
}
return (
<EmptyTableIndicatorWrapper>
<img
style={{
marginTop: props.marginTop,
width: '68px',
height: 'auto',
userSelect: 'none',
opacity: '1',
}}
src={`/assets/images/${theme.imgDir}/no-data.svg`}
alt="No Data"
draggable="false"
/>
<div
style={{
paddingTop: '2px',
fontSize: '0.85rem',
marginBottom: props.marginTop,
}}
>
<I s={text} />
</div>
</EmptyTableIndicatorWrapper>
);
}
Example #12
Source File: TradePanelWarnMessage.js From loopring-pay with Apache License 2.0 | 6 votes |
TradePanelWarnMessage = ({ show, message }) => {
return (
<div
style={{
display: show ? "initial" : "none",
fontSize: "0.85rem",
color: useContext(ThemeContext).orange,
height: "24px",
fontWeight: "600",
}}
>
<FontAwesomeIcon
style={{ marginRight: "8px" }}
size="1x"
icon={faExclamationTriangle}
/>
<I s={message} />
</div>
);
}
Example #13
Source File: TableLoadingSpin.js From dexwebapp with Apache License 2.0 | 6 votes |
TableLoadingSpin = ({ children, loading }) => {
const theme = useContext(ThemeContext);
return (
<Spin
spinning={loading ? true : false}
size="large"
indicator={
<img
alt="loading..."
src={`/assets/images/${theme.imgDir}/bars.svg`}
style={{
marginTop: '100px',
height: '40px',
opacity: '1',
}}
/>
}
>
{children}
</Spin>
);
}
Example #14
Source File: OrderRow.js From loopring-pay with Apache License 2.0 | 6 votes |
EmptyOrderRow = () => {
const theme = useContext(ThemeContext);
return (
<CompactOrderTableRow style={{ userSelect: "none" }}>
<CompactOrderTablePriceColumn
style={{ color: theme.inputPlaceHolderColor }}
>
-
</CompactOrderTablePriceColumn>
<CompactOrderTableSizeColumn
style={{ color: theme.inputPlaceHolderColor }}
>
-
</CompactOrderTableSizeColumn>
<CompactOrderTablePositionColumn
style={{ color: theme.inputPlaceHolderColor }}
>
-
</CompactOrderTablePositionColumn>
</CompactOrderTableRow>
);
}
Example #15
Source File: PanelHeader.js From dexwebapp with Apache License 2.0 | 6 votes |
PanelHeader = ({ headerText }) => {
const theme = useContext(ThemeContext);
return (
<div
style={{
height: '44px',
lineHeight: '20px',
paddingTop: '12px',
paddingBottom: '12px',
paddingLeft: '0px',
paddingRight: '0px',
position: 'relative',
fontWeight: '600',
fontSize: '0.9rem',
userSelect: 'none',
color: theme.textWhite,
}}
>
{headerText}
</div>
);
}
Example #16
Source File: TableLoadingSpin.js From loopring-pay with Apache License 2.0 | 6 votes |
TableLoadingSpin = ({ children, loading }) => {
const theme = useContext(ThemeContext);
return (
<Spin
spinning={loading ? true : false}
size="large"
indicator={
<img
alt="loading..."
src={`assets/images/${theme.imgDir}/bars.svg`}
style={{
marginTop: "100px",
height: "40px",
opacity: "1",
}}
/>
}
>
{children}
</Spin>
);
}
Example #17
Source File: Chart.js From gitpedia with MIT License | 5 votes |
PieChart = ({ starData }) => {
const themeContext = useContext(ThemeContext);
let data = {};
if (starData.data) {
// Only display chart if there is at least 1 star available
let sum = starData.data.reduce((a, b) => a + b, 0);
if (sum > 0) {
data = {
labels: starData.label,
datasets: [
{
label: "",
data: starData.data,
backgroundColor: bgColor,
borderWidth: 0,
},
],
};
}
}
return (
<>
<Pie
data={data}
// height={300}
options={{
maintainAspectRatio: false,
responsive: true,
aspectRatio: 1,
title: {
display: false,
},
legend: {
// display: false,
position: "bottom",
labels: {
fontColor: themeContext.textColor,
}
},
}}
/>
</>
);
}
Example #18
Source File: PayTable.js From loopring-pay with Apache License 2.0 | 5 votes |
PayTable = ({
columnBuilders,
rowData,
emptyText,
margin,
loading,
}) => {
const theme = useContext(ThemeContext);
const _rowData = rowData || [];
const customizeRenderEmpty = () => <EmptyTableIndicator text={emptyText} />;
const columns = columnBuilders.map((builder, j) => ({
...builder,
dataIndex: "col_" + j,
}));
const dataSource = _rowData.map((row, i) => {
var rowValue = { key: i };
columnBuilders.forEach((builder, j) => {
rowValue["col_" + j] = (
<Cell margin={margin}>{builder.getColValue(row)}</Cell>
);
});
return rowValue;
});
return (
<SimpleTableContainer>
<ConfigProvider
renderEmpty={dataSource.length === 0 && customizeRenderEmpty}
>
<TableLoadingSpin loading={loading}>
<Table
showHeader={false}
tableLayout="auto"
dataSource={dataSource}
columns={columns}
pagination={false}
/>
</TableLoadingSpin>
{/* {dataSource.length > 10 ? (
<Pagination
style={{
padding: '30px 0px',
background: theme.background,
textAlign: 'center',
}}
size=""
total={dataSource.length}
pageSize={10}
/>
) : (
<div />
)} */}
</ConfigProvider>
</SimpleTableContainer>
);
}
Example #19
Source File: useTheme.js From plataforma-sabia with MIT License | 5 votes |
function useTheme() {
const themeContext = useContext(ThemeContext);
return themeContext;
}
Example #20
Source File: SideBarDrawer.js From loopring-pay with Apache License 2.0 | 5 votes |
SideBarDrawer = ({ header, body, footer, onClose, visible }) => {
const theme = useContext(ThemeContext);
return (
<Drawer
width={241}
placement="right"
closable={false}
onClose={onClose}
visible={visible}
drawerStyle={{
fontSize: "0.85rem",
background: theme.sidePanelBackground,
}}
bodyStyle={{
padding: "0",
}}
headerStyle={{
height: 0,
}}
>
<Layout
onMouseLeave={onClose}
style={{
background: "transparent",
height: "100vh",
}}
>
<div
style={{
background: theme.popupHeaderBackground,
textAlign: "center",
width: "100%",
height: AppLayout.topNavBarHeight,
lineHeight: AppLayout.topNavBarHeight,
}}
>
{header}
</div>
<Content>{body}</Content>
</Layout>
</Drawer>
);
}
Example #21
Source File: Chart.js From gitpedia with MIT License | 5 votes |
BarChart = ({ sizeData }) => {
const themeContext = useContext(ThemeContext);
const data = {
labels: [],
datasets: [
{
label: "",
data: [],
backgroundColor: bgColor,
},
],
};
data.labels = sizeData.label;
data.datasets[0].data = sizeData.data;
const scales = {
xAxes: [
{
ticks: {
fontColor: themeContext.textColor,
fontFamily: "'Roboto', sans-serif",
fontSize: 12,
},
},
],
yAxes: [
{
ticks: {
fontColor: themeContext.textColor,
beginAtZero: true,
fontFamily: "'Roboto', sans-serif",
fontSize: 12,
},
},
],
};
return (
<>
<Bar
data={data}
options={{
maintainAspectRatio: false,
responsive: true,
title: {
display: false,
text: "Biggest Repos in Size (kb)",
fontSize: 25,
},
legend: {
display: false,
position: "right",
},
scales: scales
}}
/>
</>
);
}
Example #22
Source File: PrettyFilled.js From loopring-pay with Apache License 2.0 | 5 votes |
PrettyFilled = ({ filled }) => {
const theme = useContext(ThemeContext);
return <span style={{ color: theme.textWhite }}>{filled}</span>;
}
Example #23
Source File: Chart.js From gitpedia with MIT License | 5 votes |
DoughnutChart = () => {
const themeContext = useContext(ThemeContext);
const data = {
labels: [],
datasets: [
{
label: "",
data: [],
backgroundColor: bgColor,
borderWidth: 0,
},
],
};
return (
<LanguageContext.Consumer>
{(context) => {
const LIMIT = 10;
let labels = context.map((obj) => obj.label);
// If more than LIMIT languages then reduce it to the limit
if (labels.length >= LIMIT) {
labels = labels.slice(0, LIMIT);
}
const value = context.map((obj) => obj.value).slice(0, LIMIT);
data.labels = labels;
data.datasets[0].data = value;
return (
<Doughnut
data={data}
options={{
maintainAspectRatio: false,
responsive: true,
title: {
display: false,
},
legend: {
// display: false,
position: "bottom",
labels: {
fontColor: themeContext.textColor,
}
},
}}
/>
);
}}
</LanguageContext.Consumer>
);
}
Example #24
Source File: WidgetStats.jsx From cosmoscan-front with Apache License 2.0 | 5 votes |
WidgetStats = ({
title,
mainInfo,
sparklineData,
extraInfo,
isVertical,
tooltip,
}) => {
const theme = useContext(ThemeContext);
return (
<Card modifiers="height100">
<CardBodyWidget>
<WidgetItem isVertical={isVertical}>
{tooltip ? (
<OverlayTrigger
delay={{ show: 250, hide: 400 }}
overlay={<Tooltip id="title-tooltip">{tooltip}</Tooltip>}
>
<TitleMinor>{title}</TitleMinor>
</OverlayTrigger>
) : (
<TitleMinor>{title}</TitleMinor>
)}
<div>
{sparklineData && sparklineData.length > 1 && (
<div>
<Sparkline
data={sparklineData}
color={
sparklineData[sparklineData.length - 1].y >
sparklineData[0].y
? theme.success
: theme.danger
}
/>
</div>
)}
</div>
</WidgetItem>
<WidgetItem>
<div>{mainInfo}</div>
<div>
{sparklineData && sparklineData.length && (
<Percent
prevVal={sparklineData[0].y}
currVal={sparklineData[sparklineData.length - 1].y}
/>
)}
{extraInfo}
</div>
</WidgetItem>
</CardBodyWidget>
</Card>
);
}
Example #25
Source File: SideBarDrawer.js From dexwebapp with Apache License 2.0 | 5 votes |
SideBarDrawer = ({ header, body, footer, onClose, visible }) => {
const theme = useContext(ThemeContext);
return (
<Drawer
width={241}
placement="right"
closable={false}
onClose={onClose}
visible={visible}
drawerStyle={{
fontSize: '0.85rem',
background: theme.sidePanelBackground,
}}
bodyStyle={{
padding: '0',
}}
headerStyle={{
height: 0,
}}
>
<Layout
onMouseLeave={onClose}
style={{
background: 'transparent',
height: '100vh',
}}
>
<div
style={{
background: theme.popupHeaderBackground,
textAlign: 'center',
width: '100%',
height: AppLayout.topNavBarHeight,
lineHeight: AppLayout.topNavBarHeight,
}}
>
{header}
</div>
<Content>{body}</Content>
</Layout>
</Drawer>
);
}
Example #26
Source File: Anchor.js From VTour with MIT License | 5 votes |
Anchor = forwardRef(function (_ref, ref) {
var a11yTitle = _ref.a11yTitle,
children = _ref.children,
color = _ref.color,
disabled = _ref.disabled,
href = _ref.href,
icon = _ref.icon,
label = _ref.label,
_onBlur = _ref.onBlur,
onClick = _ref.onClick,
_onFocus = _ref.onFocus,
reverse = _ref.reverse,
rest = _objectWithoutPropertiesLoose(_ref, ["a11yTitle", "children", "color", "disabled", "href", "icon", "label", "onBlur", "onClick", "onFocus", "reverse"]);
var theme = useContext(ThemeContext) || defaultProps.theme;
var _useState = useState(),
focus = _useState[0],
setFocus = _useState[1];
useEffect(function () {
if ((icon || label) && children) {
console.warn('Anchor should not have children if icon or label is provided');
}
}, [children, icon, label]);
var coloredIcon = icon;
if (icon && !icon.props.color) {
coloredIcon = cloneElement(icon, {
color: normalizeColor(color || theme.anchor.color, theme)
});
}
var first = reverse ? label : coloredIcon;
var second = reverse ? coloredIcon : label;
return React.createElement(StyledAnchor, _extends({}, rest, {
ref: ref,
"aria-label": a11yTitle,
colorProp: color,
disabled: disabled,
hasIcon: !!icon,
focus: focus,
hasLabel: label,
reverse: reverse,
href: !disabled ? href : undefined,
onClick: !disabled ? onClick : undefined,
onFocus: function onFocus(event) {
setFocus(true);
if (_onFocus) _onFocus(event);
},
onBlur: function onBlur(event) {
setFocus(false);
if (_onBlur) _onBlur(event);
}
}), first && second ? React.createElement(Box, {
as: "span",
direction: "row",
align: "center",
gap: "small",
style: {
display: 'inline-flex'
}
}, first, second) : first || second || children);
})
Example #27
Source File: VoterActivity.jsx From cosmoscan-front with Apache License 2.0 | 5 votes |
VoterActivity = ({ isLoading, data }) => {
const theme = useContext(ThemeContext);
const [proposals, setProposals] = useState([]);
const [currVoterType, setCurrVoterType] = useState(voterTypes[0]);
useEffect(() => {
setProposals(handleProposals(data, currVoterType));
}, [data, currVoterType]);
const handleChange = (opt) => {
setCurrVoterType(opt.value);
};
return (
<ChartContainer
title={chartName}
titleTooltip={tooltipTxt}
select={(
<SelectCustom
opts={voterTypes}
defaultOpt={voterTypes[0]}
onChange={handleChange}
/>
)}
chart={(
<BarChart
isLoading={isLoading}
data={proposals}
yAxisWidth={yAxisWidth}
yAxisTickCount={yAxisTickCount}
yAxisLabelsFormatter={formatNum}
xAxisTickFormatter={formatId}
tooltipLabelFormatter={tooltipLabelFormatter}
tooltipFormatter={formatNum}
barColor={theme.navyBlue}
barName={barName}
/>
)}
/>
);
}
Example #28
Source File: LayerContainer.js From VTour with MIT License | 5 votes |
_defineProperty(LayerContainer, "contextType", ThemeContext);
Example #29
Source File: index.js From code-resume with MIT License | 5 votes |
Editor = (props) => {
const theme = useContext(ThemeContext);
const tab = props.path;
const fTabName = tab.charAt(0).toUpperCase();
const rTabName = tab.slice(1);
const content = props.data && props.data[tab];
const head = `import ${fTabName}${rTabName} from '${fTabName}${rTabName}'`;
let count = 0, color = '';
const header = head.split(' ').map((str, index) => {
return (
<Span
initial={{ y: -50 }}
animate={{y: 0}}
transition={{ duration: .3 }}
key={str} color={theme.headerColor[`color${index}`]}>
{str}
</Span>
)
});
const detail = content.split("\n").map((str, index) => {
if (count >= 6) count = 0;
if (index >= 6) {
color = theme.contentColor[`color${count}`];
count++;
} else {
color = theme.contentColor[`color${index}`]
}
let renderPre = (
<Pre
initial={{ x: 10 }}
animate={{x: 0}}
whileHover={{ x: 5 }}
transition={{ duration: .2 }}
key={`${str + index}-detail`}
color={color}
>{str}</Pre>
);
if (str.includes('href=')) {
renderPre = (
<Pre
initial={{ x: 10 }}
animate={{x: 0}}
whileHover={{ x: 5 }}
transition={{ duration: .2 }}
key={`${str + index}-detail`}
color={color}
dangerouslySetInnerHTML={{__html: str}}></Pre>
)
}
return (
<PageWrap key={index}>
<LineNo>{index + 2}</LineNo>
{renderPre}
</PageWrap>
)
});
return (
<Wrapper>
<FirstLineNo>1</FirstLineNo>
{header}
{detail}
</Wrapper>
)
}