Fix the icon color + allow changing icons depending on the state
This commit is contained in:
parent
2c433c7df0
commit
bcb35877c1
7 changed files with 47 additions and 13 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// @flow
|
||||
import React from "react";
|
||||
import _ from "lodash";
|
||||
|
||||
export default function parseIconName(name: string): string {
|
||||
return `mdi ${name.split(" ").map((icon) => "mdi-".concat(icon)).join(" ")}`;
|
||||
|
|
@ -8,3 +9,17 @@ export default function parseIconName(name: string): string {
|
|||
export const renderIcon = (name: string, extraClass?: string) => {
|
||||
return <i className={`${extraClass || ""} ${parseIconName(name)}`}></i>;
|
||||
};
|
||||
|
||||
export const controlGetIcon = (control: Control, state: State): string => {
|
||||
return typeof control.icon !== "function" ? control.icon
|
||||
: control.icon(
|
||||
_.mapValues(state, (x) => x.internal || x.actual),
|
||||
_.mapValues(state, (x) => x.actual),
|
||||
state
|
||||
);
|
||||
};
|
||||
|
||||
export const renderControlIcon = (control: Control,
|
||||
state: State, extraClass?: string) => {
|
||||
return renderIcon(controlGetIcon(control, state), extraClass);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue