File tree Expand file tree Collapse file tree 6 files changed +74
-36
lines changed Expand file tree Collapse file tree 6 files changed +74
-36
lines changed Original file line number Diff line number Diff line change 11## v2.0.19
2- - feat: sidebar set active using query string
2+ - refactor: extract getCssCustomProperties function
3+ - feat: add getColor function
4+ - feat: sidebar set active using query string PR #21
35- chore: update ` node-sass ` to ` 4.9.4 `
46- chore: update ` eslint ` to ` 5.7.0 `
57- chore: update ` babel-plugin-istanbul ` to ` 5.1.0 `
Original file line number Diff line number Diff line change 1+ /**
2+ * --------------------------------------------------------------------------
3+ * CoreUI Utilities (v2.0.18): get-color.js
4+ * Licensed under MIT (https://coreui.io/license)
5+ * --------------------------------------------------------------------------
6+ */
7+ import getCssCustomProperties from './get-css-custom-properties'
8+
9+ const minIEVersion = 10
10+ const isIE1x = ( ) => Boolean ( document . documentMode ) && document . documentMode >= minIEVersion
11+ const isCustomProperty = ( property ) => property . match ( / ^ - - .* / i)
12+
13+ const getColor = ( rawProperty , element = document . body ) => {
14+ const property = `--${ rawProperty } `
15+ let style
16+ if ( isCustomProperty ( property ) && isIE1x ( ) ) {
17+ const cssCustomProperties = getCssCustomProperties ( )
18+ style = cssCustomProperties [ property ]
19+ } else {
20+ style = window . getComputedStyle ( element , null ) . getPropertyValue ( property ) . replace ( / ^ \s / , '' )
21+ }
22+ return style ? style : rawProperty
23+ }
24+
25+ export default getColor
Original file line number Diff line number Diff line change 1+ /**
2+ * --------------------------------------------------------------------------
3+ * CoreUI Utilities (v2.0.18): get-css-custom-properties.js
4+ * Licensed under MIT (https://coreui.io/license)
5+ * @returns {string } css custom property name
6+ * --------------------------------------------------------------------------
7+ */
8+ const getCssCustomProperties = ( ) => {
9+ const cssCustomProperties = { }
10+ const sheets = document . styleSheets
11+ let cssText = ''
12+ for ( let i = sheets . length - 1 ; i > - 1 ; i -- ) {
13+ const rules = sheets [ i ] . cssRules
14+ for ( let j = rules . length - 1 ; j > - 1 ; j -- ) {
15+ if ( rules [ j ] . selectorText === '.ie-custom-properties' ) {
16+ cssText = rules [ j ] . cssText
17+ break
18+ }
19+ }
20+ if ( cssText ) {
21+ break
22+ }
23+ }
24+
25+ cssText = cssText . substring (
26+ cssText . lastIndexOf ( '{' ) + 1 ,
27+ cssText . lastIndexOf ( '}' )
28+ )
29+
30+ cssText . split ( ';' ) . forEach ( ( property ) => {
31+ if ( property ) {
32+ const name = property . split ( ': ' ) [ 0 ]
33+ const value = property . split ( ': ' ) [ 1 ]
34+ if ( name && value ) {
35+ cssCustomProperties [ `--${ name . trim ( ) } ` ] = value . trim ( )
36+ }
37+ }
38+ } )
39+ return cssCustomProperties
40+ }
41+
42+ export default getCssCustomProperties
Original file line number Diff line number Diff line change 44 * Licensed under MIT (https://coreui.io/license)
55 * --------------------------------------------------------------------------
66 */
7-
8- const getCssCustomProperties = ( ) => {
9- const cssCustomProperties = { }
10- const sheets = document . styleSheets
11- let cssText = ''
12- for ( let i = sheets . length - 1 ; i > - 1 ; i -- ) {
13- const rules = sheets [ i ] . cssRules
14- for ( let j = rules . length - 1 ; j > - 1 ; j -- ) {
15- if ( rules [ j ] . selectorText === '.ie-custom-properties' ) {
16- cssText = rules [ j ] . cssText
17- break
18- }
19- }
20- if ( cssText ) {
21- break
22- }
23- }
24-
25- cssText = cssText . substring (
26- cssText . lastIndexOf ( '{' ) + 1 ,
27- cssText . lastIndexOf ( '}' )
28- )
29-
30- cssText . split ( ';' ) . forEach ( ( property ) => {
31- if ( property ) {
32- const name = property . split ( ': ' ) [ 0 ]
33- const value = property . split ( ': ' ) [ 1 ]
34- if ( name && value ) {
35- cssCustomProperties [ `--${ name . trim ( ) } ` ] = value . trim ( )
36- }
37- }
38- } )
39- return cssCustomProperties
40- }
7+ import getCssCustomProperties from './get-css-custom-properties'
418
429const minIEVersion = 10
4310const isIE1x = ( ) => Boolean ( document . documentMode ) && document . documentMode >= minIEVersion
Original file line number Diff line number Diff line change 11import deepObjectsMerge from './deep-objects-merge'
2+ import getColor from './get-color'
23import getStyle from './get-style'
34import hexToRgb from './hex-to-rgb'
45import hexToRgba from './hex-to-rgba'
56import rgbToHex from './rgb-to-hex'
67
78export {
89 deepObjectsMerge ,
10+ getColor ,
911 getStyle ,
1012 hexToRgb ,
1113 hexToRgba ,
Original file line number Diff line number Diff line change 6262@import " rtl" ;
6363
6464// Custom Properties support for Internet Explorer
65- @import " ie-custom-properties"
65+ @import " ie-custom-properties" ;
You can’t perform that action at this time.
0 commit comments