mirror of
https://github.com/elementor/hello-theme.git
synced 2026-07-28 15:06:20 +08:00
Some checks failed
Build / Build theme (push) Failing after 1s
Lint / ESLint (push) Failing after 0s
PHPUnit / File Diff (push) Failing after 1s
Lint / PHPCS (push) Failing after 41s
PHPUnit / PHPUnit - WordPress 6.8 - PHP version 7.4 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.9 - PHP version 7.4 (push) Has been skipped
PHPUnit / PHPUnit - WordPress latest - PHP version 7.4 (push) Has been skipped
PHPUnit / PHPUnit - WordPress nightly - PHP version 7.4 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.8 - PHP version 8.0 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.9 - PHP version 8.0 (push) Has been skipped
PHPUnit / PHPUnit - WordPress latest - PHP version 8.0 (push) Has been skipped
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.0 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.8 - PHP version 8.1 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.9 - PHP version 8.1 (push) Has been skipped
PHPUnit / PHPUnit - WordPress latest - PHP version 8.1 (push) Has been skipped
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.1 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.8 - PHP version 8.2 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.9 - PHP version 8.2 (push) Has been skipped
PHPUnit / PHPUnit - WordPress latest - PHP version 8.2 (push) Has been skipped
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.2 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.8 - PHP version 8.3 (push) Has been skipped
PHPUnit / PHPUnit - WordPress 6.9 - PHP version 8.3 (push) Has been skipped
PHPUnit / PHPUnit - WordPress latest - PHP version 8.3 (push) Has been skipped
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.3 (push) Has been skipped
PHPUnit / PHPUnit - Test Results (push) Successful in 2s
* Setup prettier * Fix lint/format issues
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
import React, { useState, useEffect } from 'react';
|
|
|
|
const componentMap = {
|
|
BrandYoutubeIcon: () => import('../icons/youtube.tsx'),
|
|
BrandElementorIcon: () => import('../icons/elementor.tsx'),
|
|
ThemeBuilderIcon: () => import('@elementor/icons/ThemeBuilderIcon'),
|
|
SettingsIcon: () => import('@elementor/icons/SettingsIcon'),
|
|
BrandFacebookIcon: () => import('@elementor/icons/BrandFacebookIcon'),
|
|
StarIcon: () => import('@elementor/icons/StarIcon'),
|
|
HelpIcon: () => import('@elementor/icons/HelpIcon'),
|
|
SpeakerphoneIcon: () => import('@elementor/icons/SpeakerphoneIcon'),
|
|
TextIcon: () => import('@elementor/icons/TextIcon'),
|
|
PhotoIcon: () => import('@elementor/icons/PhotoIcon'),
|
|
AppsIcon: () => import('@elementor/icons/AppsIcon'),
|
|
BrushIcon: () => import('@elementor/icons/BrushIcon'),
|
|
UnderlineIcon: () => import('@elementor/icons/UnderlineIcon'),
|
|
PagesIcon: () => import('@elementor/icons/PagesIcon'),
|
|
PageTypeIcon: () => import('@elementor/icons/PageTypeIcon'),
|
|
HeaderTemplateIcon: () => import('@elementor/icons/HeaderTemplateIcon'),
|
|
FooterTemplateIcon: () => import('@elementor/icons/FooterTemplateIcon'),
|
|
};
|
|
|
|
const DynamicIcon = ({ componentName, ...rest }) => {
|
|
const [Component, setComponent] = useState(null);
|
|
|
|
useEffect(() => {
|
|
if (componentMap[componentName]) {
|
|
componentMap[componentName]().then((module) => {
|
|
setComponent(() => module.default);
|
|
});
|
|
}
|
|
}, [componentName]);
|
|
|
|
if (!Component) {
|
|
return null;
|
|
}
|
|
|
|
return <Component {...rest} />;
|
|
};
|
|
|
|
export default DynamicIcon;
|