Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4b9e9336
Commit
4b9e9336
authored
Jan 18, 2019
by
Dominik Prokop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added config provider to be able to access config easily from react components
parent
33fa40a1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletions
+30
-1
public/app/core/utils/ConfigProvider.tsx
+28
-0
public/app/core/utils/react2angular.ts
+2
-1
No files found.
public/app/core/utils/ConfigProvider.tsx
0 → 100644
View file @
4b9e9336
import
React
from
'react'
;
import
config
,
{
Settings
}
from
'app/core/config'
;
import
{
GrafanaTheme
}
from
'@grafana/ui'
;
export
const
ConfigContext
=
React
.
createContext
<
Settings
>
(
config
);
export
const
ConfigConsumer
=
ConfigContext
.
Consumer
;
export
const
provideConfig
=
(
component
:
React
.
ComponentType
<
any
>
)
=>
{
const
ConfigProvider
=
(
props
:
any
)
=>
(
<
ConfigContext
.
Provider
value=
{
config
}
>
{
React
.
createElement
(
component
,
{
...
props
})
}
</
ConfigContext
.
Provider
>
);
return
ConfigProvider
;
};
interface
ThemeProviderProps
{
children
:
(
theme
:
GrafanaTheme
)
=>
JSX
.
Element
;
}
export
const
ThemeProvider
=
({
children
}:
ThemeProviderProps
)
=>
{
return
(
<
ConfigConsumer
>
{
({
bootData
})
=>
{
return
children
(
bootData
.
user
.
lightTheme
?
GrafanaTheme
.
Light
:
GrafanaTheme
.
Dark
);
}
}
</
ConfigConsumer
>
);
};
public/app/core/utils/react2angular.ts
View file @
4b9e9336
import
coreModule
from
'app/core/core_module'
;
import
coreModule
from
'app/core/core_module'
;
import
{
provideConfig
}
from
'app/core/utils/ConfigProvider'
;
export
function
react2AngularDirective
(
name
:
string
,
component
:
any
,
options
:
any
)
{
export
function
react2AngularDirective
(
name
:
string
,
component
:
any
,
options
:
any
)
{
coreModule
.
directive
(
name
,
[
coreModule
.
directive
(
name
,
[
'reactDirective'
,
'reactDirective'
,
reactDirective
=>
{
reactDirective
=>
{
return
reactDirective
(
component
,
options
);
return
reactDirective
(
provideConfig
(
component
)
,
options
);
},
},
]);
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment