2016-12-06 13:50:24 +02:00
|
|
|
const styled = require('styled-components');
|
|
|
|
|
|
|
|
|
2016-10-28 17:14:35 +03:00
|
|
|
const calc = require('reduce-css-calc');
|
|
|
|
const traverse = require('traverse');
|
|
|
|
const isFunction = require('lodash.isfunction');
|
|
|
|
const Color = require('color');
|
|
|
|
|
|
|
|
const tables = {
|
2016-12-06 13:50:24 +02:00
|
|
|
bg: 'transparent',
|
|
|
|
cellPadding: '.75rem'
|
2016-10-28 17:14:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// github.com/kristoferjoseph/flexboxgrid/blob/master/dist/flexboxgrid.css
|
|
|
|
const sizes = {
|
2016-12-06 13:50:24 +02:00
|
|
|
gridColumns: 12,
|
2016-10-28 17:14:35 +03:00
|
|
|
gutterWidth: '1rem',
|
|
|
|
outerMargin: '2rem',
|
|
|
|
gutterCompensation: ({
|
|
|
|
gutterWidth
|
|
|
|
}) => {
|
|
|
|
return calc(`calc((${gutterWidth} * 0.5) * -1)`);
|
|
|
|
},
|
|
|
|
halfGutterWidth: ({
|
|
|
|
gutterWidth
|
|
|
|
}) => {
|
|
|
|
return calc(`calc(${gutterWidth} * 0.5)`);
|
|
|
|
},
|
|
|
|
xsMin: 30,
|
|
|
|
smMin: 48,
|
|
|
|
mdMin: 64,
|
|
|
|
lgMin: 75,
|
|
|
|
screenXsMin: ({
|
|
|
|
xsMin
|
|
|
|
}) => {
|
|
|
|
return `${xsMin}em`;
|
|
|
|
},
|
|
|
|
screenSmMin: ({
|
|
|
|
smMin
|
|
|
|
}) => {
|
|
|
|
return `${smMin}em`;
|
|
|
|
},
|
|
|
|
screenMdMin: ({
|
|
|
|
mdMin
|
|
|
|
}) => {
|
|
|
|
return `${mdMin}em`;
|
|
|
|
},
|
|
|
|
screenLgMin: ({
|
|
|
|
lgMin
|
|
|
|
}) => {
|
|
|
|
return `${lgMin}em`;
|
|
|
|
},
|
|
|
|
containerSm: ({
|
|
|
|
gutterWidth,
|
|
|
|
smMin
|
|
|
|
}) => {
|
|
|
|
return calc(`calc(${smMin} + ${gutterWidth})`);
|
|
|
|
},
|
|
|
|
containerMd: ({
|
|
|
|
gutterWidth,
|
|
|
|
mdMin
|
|
|
|
}) => {
|
|
|
|
return calc(`calc(${mdMin} + ${gutterWidth})`);
|
|
|
|
},
|
|
|
|
containerLg: ({
|
|
|
|
gutterWidth,
|
|
|
|
lgMin
|
|
|
|
}) => {
|
|
|
|
return calc(`calc(${lgMin} + ${gutterWidth})`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-28 19:36:44 +03:00
|
|
|
const boxes = {
|
2016-10-31 19:23:16 +02:00
|
|
|
borderRadius: '4px',
|
2016-10-31 14:03:41 +02:00
|
|
|
bottomShaddow: '0 2px 0 0 rgba(0, 0, 0, 0.05)',
|
2016-10-31 14:25:20 +02:00
|
|
|
insetShaddow: 'inset 0 3px 0 0 rgba(0, 0, 0, 0.05)',
|
2016-10-31 14:08:05 +02:00
|
|
|
border: {
|
|
|
|
checked: '1px solid #2532bb',
|
|
|
|
unchecked: '1px solid #d8d8d8',
|
|
|
|
confirmed: '1px solid #23AC32'
|
|
|
|
}
|
2016-10-28 19:36:44 +03:00
|
|
|
};
|
|
|
|
|
2016-10-28 17:14:35 +03:00
|
|
|
const forms = {
|
|
|
|
cursorDisabled: 'not-allowed'
|
|
|
|
};
|
|
|
|
|
|
|
|
const colors = {
|
2016-10-28 19:36:44 +03:00
|
|
|
brandPrimary: '#364acd',
|
|
|
|
brandSecondary: '#160d42',
|
2016-10-28 17:14:35 +03:00
|
|
|
grayLight: '#818a91',
|
2016-10-31 14:03:41 +02:00
|
|
|
confirmation: '#38C647',
|
|
|
|
background: '#ffffff',
|
|
|
|
border: '#D8D8D8',
|
2016-11-28 19:53:40 +02:00
|
|
|
borderSelected: '#1D35BC',
|
|
|
|
warning: '#e4a800',
|
|
|
|
warningLight: '#fffaed',
|
|
|
|
alert: '#D0011B',
|
|
|
|
alertLight: '#ffc7c7'
|
2016-10-28 17:14:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const typography = {
|
|
|
|
dtFontWeight: 'bold',
|
|
|
|
abbrBorderColor: colors.grayLight,
|
|
|
|
textMuted: colors.grayLight
|
|
|
|
};
|
|
|
|
|
|
|
|
const links = {
|
2016-12-06 13:50:24 +02:00
|
|
|
color: colors.brandPrimary,
|
|
|
|
decoration: 'none',
|
|
|
|
hoverColor: ({
|
|
|
|
color
|
2016-10-28 17:14:35 +03:00
|
|
|
}) => {
|
2016-12-06 13:50:24 +02:00
|
|
|
return Color(color).darken(0.15).hex();
|
2016-10-28 17:14:35 +03:00
|
|
|
},
|
2016-12-06 13:50:24 +02:00
|
|
|
hoverDecoration: 'underline'
|
2016-10-28 17:14:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// github.com/kristoferjoseph/flexboxgrid/blob/master/dist/flexboxgrid.css
|
2016-12-06 13:50:24 +02:00
|
|
|
const screens = {
|
2016-10-28 17:14:35 +03:00
|
|
|
// >= 768px
|
2016-12-06 13:50:24 +02:00
|
|
|
small: 'only screen and (min-width: 48rem)',
|
2016-10-28 17:14:35 +03:00
|
|
|
// >= 1024px
|
2016-12-06 13:50:24 +02:00
|
|
|
medium: 'only screen and (min-width: 64rem)',
|
2016-10-28 17:14:35 +03:00
|
|
|
// >= 1200px
|
2016-12-06 13:50:24 +02:00
|
|
|
large: 'only screen and (min-width: 75rem)'
|
2016-10-28 17:14:35 +03:00
|
|
|
};
|
|
|
|
|
2016-12-06 13:50:24 +02:00
|
|
|
const breakpoints = Object.keys(screens).reduce((acc, label) => {
|
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[label]: (...args) => styled.css`
|
|
|
|
@media ${screens[label]} {
|
|
|
|
${styled.css(...args)}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
};
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
const constants = traverse({
|
2016-10-28 17:14:35 +03:00
|
|
|
colors,
|
2016-10-28 19:36:44 +03:00
|
|
|
boxes,
|
2016-10-28 17:14:35 +03:00
|
|
|
forms,
|
|
|
|
links,
|
|
|
|
sizes,
|
|
|
|
tables,
|
|
|
|
typography
|
|
|
|
}).map(function(x) {
|
|
|
|
return isFunction(x) ? x(this.parent.node) : x;
|
|
|
|
});
|
2016-12-06 13:50:24 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
...constants,
|
|
|
|
breakpoints
|
|
|
|
};
|