import { AiOutlineControl } from 'react-icons/ai'; import { skeleton } from '../../helpers/utils'; import PropTypes from 'prop-types'; const ThemeChanger = ({ theme, setTheme, loading, themeConfig }) => { const changeTheme = (e, selectedTheme) => { e.preventDefault(); document.querySelector('html').setAttribute('data-theme', selectedTheme); typeof window !== 'undefined' && localStorage.setItem('gitprofile-theme', selectedTheme); setTheme(selectedTheme); }; return (
{loading ? ( skeleton({ width: 'w-20', height: 'h-8', className: 'mb-1' }) ) : ( Theme )}
{loading ? skeleton({ width: 'w-16', height: 'h-5' }) : theme === themeConfig.default ? 'Default' : theme}
{loading ? ( skeleton({ width: 'w-14 md:w-28', height: 'h-10', className: 'mr-6', }) ) : (
Change Theme
)}
); }; ThemeChanger.propTypes = { theme: PropTypes.string.isRequired, setTheme: PropTypes.func.isRequired, loading: PropTypes.bool.isRequired, themeConfig: PropTypes.object.isRequired, }; export default ThemeChanger;