mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-24 02:27:37 +00:00
Extract skin functions
This commit is contained in:
parent
89cf922ecd
commit
dd7b94bfc3
1 changed files with 21 additions and 3 deletions
|
|
@ -83,7 +83,7 @@ const FALLBACKS = {
|
|||
MAIN_BALANCE_THUMB_ACTIVE: "MAIN_VOLUME_THUMB_SELECTED"
|
||||
};
|
||||
|
||||
const Skin = props => {
|
||||
function cssRulesFromProps(props) {
|
||||
const { skinImages, skinCursors, skinGenLetterWidths } = props;
|
||||
if (!skinImages || !skinCursors) {
|
||||
return null;
|
||||
|
|
@ -137,12 +137,10 @@ const Skin = props => {
|
|||
);
|
||||
}
|
||||
|
||||
const clipPaths = {};
|
||||
for (const [regionName, polygons] of Object.entries(props.skinRegion)) {
|
||||
if (polygons) {
|
||||
const matcher = mapRegionNamesToMatcher[regionName];
|
||||
const id = mapRegionNamesToIds[regionName];
|
||||
clipPaths[id] = polygons;
|
||||
cssRules.push(`${CSS_PREFIX} ${matcher} { clip-path: url(#${id}); }`);
|
||||
}
|
||||
}
|
||||
|
|
@ -212,6 +210,26 @@ const Skin = props => {
|
|||
}`
|
||||
);
|
||||
|
||||
return cssRules;
|
||||
}
|
||||
|
||||
function clipPathsFromProps(props) {
|
||||
const clipPaths = {};
|
||||
for (const [regionName, polygons] of Object.entries(props.skinRegion)) {
|
||||
if (polygons) {
|
||||
const id = mapRegionNamesToIds[regionName];
|
||||
clipPaths[id] = polygons;
|
||||
}
|
||||
}
|
||||
return clipPaths;
|
||||
}
|
||||
|
||||
const Skin = props => {
|
||||
const cssRules = cssRulesFromProps(props);
|
||||
if (cssRules == null) {
|
||||
return null;
|
||||
}
|
||||
const clipPaths = clipPathsFromProps(props);
|
||||
return (
|
||||
<div>
|
||||
<Css>{cssRules.join("\n")}</Css>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue