-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Services section to doc site. Add page for isColorDark.
- Loading branch information
Showing
12 changed files
with
166 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { | ||
Fragment, | ||
} from 'react'; | ||
|
||
import { | ||
EuiFlexGrid, | ||
EuiFlexItem, | ||
} from '../../../../src/components'; | ||
|
||
import { | ||
isColorDark, | ||
} from '../../../../src/services'; | ||
|
||
const SWATCH_STYLE = { | ||
width: 100, | ||
height: 100, | ||
padding: 16, | ||
}; | ||
|
||
const rgb = (r, g, b) => { | ||
return `rgb(${r}, ${g}, ${b})`; | ||
}; | ||
|
||
export default () => { | ||
const DARK_COLORS = [ | ||
[0, 104, 55], | ||
[165, 0, 38], | ||
[0, 0, 0], | ||
[219, 19, 116], | ||
[73, 0, 146], | ||
[70, 26, 10], | ||
[146, 0, 0] | ||
]; | ||
|
||
const LIGHT_COLORS = [ | ||
[191, 161, 128], | ||
[249, 133, 16], | ||
[0, 179, 164], | ||
[212, 157, 170], | ||
[255, 255, 255], | ||
[254, 182, 219], | ||
[230, 194, 32] | ||
]; | ||
|
||
return ( | ||
<Fragment> | ||
<EuiFlexGrid> | ||
{DARK_COLORS.map(color => ( | ||
<EuiFlexItem style={{ backgroundColor: rgb(...color), ...SWATCH_STYLE }} key={color.join('')}> | ||
{ | ||
isColorDark(...color) | ||
? <div style={{ color: 'white' }}>Dark</div> | ||
: <div style={{ color: 'black' }}>Light</div> | ||
} | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGrid> | ||
|
||
<EuiFlexGrid> | ||
{LIGHT_COLORS.map(color => ( | ||
<EuiFlexItem style={{ backgroundColor: rgb(...color), ...SWATCH_STYLE }} key={color.join('')}> | ||
{ | ||
isColorDark(...color) | ||
? <div style={{ color: 'white' }}>Dark</div> | ||
: <div style={{ color: 'black' }}>Light</div> | ||
} | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGrid> | ||
</Fragment> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
import { | ||
EuiCode, | ||
} from '../../../../src/components'; | ||
|
||
import IsColorDark from './is_color_dark'; | ||
const isColorDarkSource = require('!!raw-loader!./is_color_dark'); | ||
const isColorDarkHtml = renderToHtml(IsColorDark); | ||
|
||
export const IsColorDarkExample = { | ||
title: 'IsColorDark', | ||
sections: [{ | ||
title: 'IsColorDark', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: isColorDarkSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: isColorDarkHtml, | ||
}], | ||
text: ( | ||
<p> | ||
Use <EuiCode>isColorDark</EuiCode> to determine whether or not to use light or dark text | ||
against a background of a given color. | ||
</p> | ||
), | ||
demo: <IsColorDark />, | ||
}], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters