Skip to content

Commit

Permalink
update docs for css variable styling
Browse files Browse the repository at this point in the history
  • Loading branch information
catc committed Mar 29, 2020
1 parent 6d39489 commit 585bf7d
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TODO
- simple to use with many customizable options
- smooth, beautiful animations with [react spring](https://www.react-spring.io)
- typescript support
- css variable support for custom styles

## Installation

Expand Down
14 changes: 14 additions & 0 deletions docs/js/sections/api.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import Text from '../components/text'
import Link from '../components/link'
import Code, { SYNTAX } from '../components/code'

export default function Intro() {
Expand Down Expand Up @@ -156,6 +157,19 @@ export default function Intro() {
<div className="api__description">
<Text>Custom done button as render props. See below for example.</Text>
</div>

{/* custom styles */}
<h3 className="h3-api">
<code className="name">custom styling</code>
</h3>

<div className="api__description">
<Text>
<Link samePage href="#custom-styles">
See below for examples
</Link>
</Text>
</div>
</section>
)
}
2 changes: 1 addition & 1 deletion docs/js/sections/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function YourComponent(){
</div>

{/* example 4 */}
<div className="examples__item">
<div className="examples__item foo">
<Text>Custom done button</Text>

<div className="examples__example-3">
Expand Down
88 changes: 84 additions & 4 deletions docs/js/sections/other.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,97 @@
import React from 'react'

import Text from '../components/text'
import Link from '../components/link'
import Code, { SYNTAX } from '../components/code'

export default function Other() {
return (
<section className="docs-section">
<section className="docs-section" id="custom-styles">
<h2>Custom styles</h2>

<div className="examples__item">
<Text>There are two ways of overriding/customizing styles:</Text>
<Text>
<strong>CSS variables:</strong> for changing basic styling - mainly text colors,
background colors, fonts, etc. See{' '}
<Link
samePage
href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties"
>
using CSS variables
</Link>{' '}
for more info.
</Text>
<Code type={SYNTAX.css}>
{`// global override
:root {
--meridiem-bg-color: green;
--meridiem-text-color: red;
}
// container specific
.foo {
--meridiem-bg-color: green;
--meridiem-text-color: red;
}
`}
</Code>

<Text>The full list of supported variables are:</Text>
<Code type={SYNTAX.css}>
{`// main wrapper
var(--main-box-shadow, 0 3px 11px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.15))
var(--main-bg, white)
var(--main-font-family, 'Roboto', sans-serif)
// top bar
var(--top-bg, white)
var(--top-colon-color, #8C8C8C)
var(--top-text-color, #8C8C8C)
var(--top-selected-color, #8EDDFD)
var(--top-meridiem-color, #8C8C8C)
// time dropdown
var(--dropdown-border, 1px solid #f4f4f4)
var(--dropdown-shadow, 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24))
var(--dropdown-text-color, #8c8c8c)
var(--dropdown-hover-bg, #EAF8FF)
// clock wrapper
var(--clock-wrapper-bg, #f4f4f4);
var(--clock-bg, white);
// clock hand
var(--hand-line-color, #bceaff);
var(--hand-circle-center, #bceaff);
var(--hand-circle-outer, #e6f7ff);
var(--hand-minute-circle, #ade2fb); // minutes only, dot between intervals
// numbers
var(--numbers-text-color, #999);
var(--numbers-font-size-reg, 16px); // 12h mode only
var(--numbers-font-size-inner, 15px); // 24h mode only
var(--numbers-font-size-outer, 13px); // 24h mode only
// meridiem buttons
var(--meridiem-bg-color, white);
var(--meridiem-text-color, #898989);
var(--meridiem-selected-bg-color, #E1EFF6);
var(--meridiem-selected-text-color, #898989);
// done button
var(--done-bg-color, #f4f4f4);
var(--done-text-color, #686868);
var(--done-border-top, 1px solid #ccc);
var(--done-font-size, 13px);
var(--done-font-weight, 500);
`}
</Code>

<hr />
<Text>
For changing colors, each element has a class name you can override properties
with 1 level of specifity.
<strong>Higher CSS specificity:</strong> for more control over css, each element
has a class name you can override properties with 1 level of specifity.
</Text>
<Code type={SYNTAX.css}>
{`// won't work because emotion will override your styles
Expand Down

0 comments on commit 585bf7d

Please sign in to comment.