@brizy/ui
Version:
React elements in Brizy style
637 lines (561 loc) • 13.8 kB
text/less
@import url("./theme/index");
@selector: ~"[class*='@{BRZ_PREFIX}']";
// Reboot
//
// Normalization of HTML elements, manually forked from Normalize.css to remove
// styles targeting irrelevant browsers while applying new styles.
//
// Normalize is licensed MIT. https://github.com/necolas/normalize.css
// remove the clear button of a text input control in IE10+
input::-ms-clear,
input::-ms-reveal {
:where(&@{selector}),
:where(@{selector} &) {
@apply hidden;
}
}
// Document
//
// 1. Change from `box-sizing: content-box` so that `width` is not affected by `padding` or `border`.
// 2. Change the default font family in all browsers.
// 3. Correct the line height in all browsers.
// 4. Prevent adjustments of font size after orientation changes in IE on Windows Phone and in iOS.
// 5. Setting @viewport causes scrollbars to overlap content in IE11 and Edge, so
// we force a non-overlapping, non-auto-hiding scrollbar to counteract.
// 6. Change the default tap highlight to be completely transparent in iOS.
*,
*::before,
*::after {
:where(&@{selector}),
:where(@{selector} &) {
@apply box-border; // 1
}
}
html {
font-family: sans-serif; // 2
line-height: 1.15; // 3
-webkit-text-size-adjust: 100%; // 4
-ms-text-size-adjust: 100%; // 4
-ms-overflow-style: scrollbar; // 5
-webkit-tap-highlight-color: fade(@black, 0%); // 6
}
// IE10+ doesn't honor `<meta name="viewport">` in some cases.
@-ms-viewport {
width: device-width;
}
// Body
//
// 1. remove the margin in all browsers.
// 2. As a best practice, apply a default `body-background`.
body {
@apply m-0; // 1
@apply text-body-text-color;
@apply text-body-font-size;
@apply font-body-font-family;
font-variant: @font-variant-base;
@apply leading-body-line-height;
@apply bg-body-bg;
font-feature-settings: @font-feature-settings-base;
}
// Suppress the focus outline on elements that cannot be accessed via keyboard.
// This prevents an unwanted focus outline from appearing around elements that
// might still respond to pointer events.
//
// Credit: https://github.com/suitcss/base
[tabindex="-1"]:focus {
outline: none ;
}
// Content grouping
//
// 1. Add the correct box sizing in Firefox.
// 2. Show the overflow in Edge and IE.
hr {
:where(&@{selector}),
:where(@{selector} &) {
@apply box-content; //1
@apply h-0; // 1
@apply overflow-visible; // 2
}
}
//
// Typography
//
// remove top margins from headings
//
// By default, `<h1>`-`<h6>` all receive top and bottom margins. We nuke the top
// margin for easier control within type scales as it avoids margin collapsing.
h1,
h2,
h3,
h4,
h5,
h6 {
:where(&@{selector}),
:where(@{selector} &) {
@apply mt-0;
@apply mb-[.5em];
@apply font-medium;
@apply text-heading-color;
}
}
// Reset margins on paragraphs
//
// Similarly, the top margin on `<p>`s get reset. However, we also reset the
// bottom margin to use `em` units instead of `em`.
p {
:where(&@{selector}),
:where(@{selector} &) {
@apply mt-0;
@apply ~"mb-[1em]";
}
}
// Abbreviations
//
// 1. remove the bottom border in Firefox 39-.
// 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
// 3. Add explicit cursor to indicate changed behavior.
// 4. Duplicate behavior to the data-* attribute for our tooltip plugin
abbr[title],
abbr[data-original-title] {
:where(&@{selector}),
:where(@{selector} &) {
// 4
@apply underline decoration-dotted;
@apply border-b-0;
@apply cursor-help;
}
}
address {
:where(&@{selector}),
:where(@{selector} &) {
@apply ~"mb-[1em]";
@apply not-italic;
line-height: inherit;
}
}
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
:where(&@{selector}),
:where(@{selector} &) {
-webkit-appearance: none;
}
}
ol,
ul,
dl {
:where(&@{selector}),
:where(@{selector} &) {
@apply m-0;
@apply list-none;
@apply p-0;
}
}
ol ol,
ul ul,
ol ul,
ul ol {
:where(&@{selector}),
:where(@{selector} &) {
@apply mb-0;
}
}
dt {
:where(&@{selector}),
:where(@{selector} &) {
@apply font-medium;
}
}
dd {
:where(&@{selector}),
:where(@{selector} &) {
@apply mb-[.5em];
@apply ml-0; // Undo browser default
}
}
blockquote {
:where(&@{selector}),
:where(@{selector} &) {
@apply mt-0;
@apply mr-0;
@apply ~"mb-[1em]";
}
}
dfn {
:where(&@{selector}),
:where(@{selector} &) {
@apply italic; // Add the correct font style in Android 4.3-
}
}
b,
strong {
:where(&@{selector}),
:where(@{selector} &) {
font-weight: bolder; // Add the correct font weight in Chrome, Edge, and Safari
}
}
small {
:where(&@{selector}),
:where(@{selector} &) {
@apply ~"text-[80%]"; // Add the correct font size in all browsers
}
}
//
// Prevent `sub` and `sup` elements from affecting the line height in
// all browsers.
//
sub,
sup {
:where(&@{selector}),
:where(@{selector} &) {
@apply relative;
@apply ~"text-[75%]";
@apply ~"leading-[0]";
@apply align-baseline;
}
}
sub {
:where(&@{selector}),
:where(@{selector} &) {
@apply -bottom-[.25em];
}
}
sup {
:where(&@{selector}),
:where(@{selector} &) {
@apply -top-[.5em];
}
}
//
// Links
//
a {
:where(&@{selector}),
:where(@{selector} &) {
color: @link-color;
text-decoration: @link-decoration;
@apply bg-transparent; // remove the gray background on active links in IE 10.
outline: none;
@apply cursor-pointer;
@apply ~"transition-[color]";
@apply duration-300;
-webkit-text-decoration-skip: objects; // remove gaps in links underline in iOS 8+ and Safari 8+.
&:hover {
@apply text-link-text-color--hover;
}
&:active {
color: @link-active-color;
}
&:active,
&:hover {
text-decoration: @link-hover-decoration;
@apply outline-0;
}
// https://github.com/ant-design/ant-design/issues/22503
&:focus {
text-decoration: @link-focus-decoration;
outline: @link-focus-outline;
}
&[disabled] {
@apply text-link-text-color--disabled;
@apply cursor-not-allowed;
@apply pointer-events-none;
}
}
}
//
// Code
//
pre,
code,
kbd,
samp {
:where(&@{selector}),
:where(@{selector} &) {
@apply ~"text-[1em]"; // Correct the odd `em` font sizing in all browsers.
@apply font-code-font-family;
}
}
pre {
:where(&@{selector}),
:where(@{selector} &) {
// remove browser default top margin
@apply mt-0;
// Reset browser default of `1em` to use `em`s
@apply ~"mb-[1em]";
// Don't allow content to break outside
@apply overflow-auto;
}
}
//
// Figures
//
figure {
:where(&@{selector}),
:where(@{selector} &) {
// Apply a consistent margin strategy (matches our type styles).
@apply mt-0 mr-0;
@apply ~"mb-[1em]";
}
}
//
// Images and content
//
img {
:where(&@{selector}),
:where(@{selector} &) {
@apply align-middle;
@apply border-none; // remove the border on images inside links in IE 10-.
}
}
svg:not(:root) {
:where(&@{selector}),
:where(@{selector} &) {
@apply overflow-hidden; // Hide the overflow in IE
}
}
// Avoid 300ms click delay on touch devices that support the `touch-action` CSS property.
//
// In particular, unlike most other browsers, IE11+Edge on Windows 10 on touch devices and IE Mobile 10-11
// DON'T remove the click delay when `<meta name="viewport" content="width=device-width">` is present.
// However, they DO support emoving the click delay via `touch-action: manipulation`.
// See:
// * https://getbootstrap.com/docs/4.0/content/reboot/#click-delay-optimization-for-touch
// * http://caniuse.com/#feat=css-touch-action
// * https://patrickhlauke.github.io/touch/tests/results/#suppressing-300ms-delay
a,
area,
button,
[role="button"],
input:not([type="range"]),
label,
select,
summary,
textarea {
:where(&@{selector}),
:where(@{selector} &) {
@apply touch-manipulation;
}
}
//
// Tables
//
table {
:where(&@{selector}),
:where(@{selector} &) {
@apply border-collapse; // Prevent double borders
}
}
caption {
:where(&@{selector}),
:where(@{selector} &) {
@apply pt-[.75em] pb-[.3em];
color: @text-color-secondary;
@apply text-left;
@apply caption-bottom;
}
}
th {
:where(&@{selector}),
:where(@{selector} &) {
// Matches default `<td>` alignment by inheriting from the `<body>`, or the
// closest parent with a set `text-align`.
text-align: inherit;
}
}
//
// Forms
//
input,
button,
select,
optgroup,
textarea {
:where(&@{selector}),
:where(@{selector} &) {
@apply m-0;
@apply text-inherit;
font-size: inherit;
font-family: inherit;
@apply ~"leading-[inherit]";
}
}
button,
input {
:where(&@{selector}),
:where(@{selector} &) {
@apply overflow-visible; // Show the overflow in Edge
}
}
button,
select {
:where(&@{selector}),
:where(@{selector} &) {
@apply normal-case; // remove the inheritance of text transform in Firefox
}
}
// 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
// controls in Android 4.
// 2. Correct the inability to style clickable types in iOS and Safari.
button,
html [type="button"], /* 1 */
[type="reset"],
[type="submit"] {
:where(&@{selector}),
:where(@{selector} &) {
-webkit-appearance: button; // 2
}
}
// remove inner border and padding from Firefox, but don't restore the outline like Normalize.
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
:where(&@{selector}),
:where(@{selector} &) {
@apply p-0;
@apply border-none;
}
}
input[type="radio"],
input[type="checkbox"] {
:where(&@{selector}),
:where(@{selector} &) {
@apply box-border; // 1. Add the correct box sizing in IE 10-
@apply p-0; // 2. remove the padding in IE 10-
}
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
// remove the default appearance of temporal inputs to avoid a Mobile Safari
// bug where setting a custom line-height prevents text from being vertically
// centered within the input.
// See https://bugs.webkit.org/show_bug.cgi?id=139848
// and https://github.com/twbs/bootstrap/issues/11266
:where(&@{selector}),
:where(@{selector} &) {
-webkit-appearance: listbox;
}
}
textarea {
:where(&@{selector}),
:where(@{selector} &) {
@apply overflow-auto; // remove the default vertical scrollbar in IE.
// Textareas should really only resize vertically so they don't break their (horizontal) containers.
@apply resize-y;
}
}
fieldset {
:where(&@{selector}),
:where(@{selector} &) {
// Browsers set a default `min-width: min-content;` on fieldsets,
// unlike e.g. `<div>`s, which have `min-width: 0;` by default.
// So we reset that to ensure fieldsets behave more like a standard block element.
// See https://github.com/twbs/bootstrap/issues/12359
// and https://html.spec.whatwg.org/multipage/#the-fieldset-and-legend-elements
@apply min-w-0 m-0;
// Reset the default outline behavior of fieldsets so they don't affect page layout.
@apply p-0 border-0;
}
}
// 1. Correct the text wrapping in Edge and IE.
// 2. Correct the color inheritance from `fieldset` elements in IE.
legend {
:where(&@{selector}),
:where(@{selector} &) {
@apply block w-full max-w-full;
@apply mb-[.5em];
@apply p-0;
@apply text-inherit;
@apply ~"text-[1.5em]";
line-height: inherit;
@apply whitespace-normal;
}
}
progress {
:where(&@{selector}),
:where(@{selector} &) {
@apply align-baseline; // Add the correct vertical alignment in Chrome, Firefox, and Opera.
}
}
// Correct the cursor style of incement and decement buttons in Chrome.
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
:where(&@{selector}),
:where(@{selector} &) {
@apply h-auto;
}
}
[type="search"] {
:where(&@{selector}),
:where(@{selector} &) {
// This overrides the extra rounded corners on search inputs in iOS so that our
// `.form-control` class can properly style them. Note that this cannot simply
// be added to `.form-control` as it's not specific enough. For details, see
// https://github.com/twbs/bootstrap/issues/11586.
@apply -outline-offset-2; // 2. Correct the outline style in Safari.
-webkit-appearance: none;
}
}
//
// remove the inner padding and cancel buttons in Chrome and Safari on macOS.
//
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
:where(&@{selector}),
:where(@{selector} &) {
-webkit-appearance: none;
}
}
//
// 1. Correct the inability to style clickable types in iOS and Safari.
// 2. Change font properties to `inherit` in Safari.
//
::-webkit-file-upload-button {
font: inherit; // 2
-webkit-appearance: button; // 1
}
//
// Correct element displays
//
output {
:where(&@{selector}),
:where(@{selector} &) {
@apply inline-block;
}
}
summary {
:where(&@{selector}),
:where(@{selector} &) {
@apply list-item; // Add the correct display in all browsers
}
}
template {
:where(&@{selector}),
:where(@{selector} &) {
@apply hidden; // Add the correct display in IE
}
}
// Always hide an element with the `hidden` HTML attribute (from PureCSS).
// Needed for proper display in IE 10-.
[hidden] {
:where(&@{selector}),
:where(@{selector} &) {
@apply !hidden;
}
}
mark {
:where(&@{selector}),
:where(@{selector} &) {
@apply ~"p-[.2em]";
background-color: @yellow-1;
}
}
::selection {
@apply text-selection-text-color;
@apply bg-selection-bg;
background: @text-selection-bg;
}