using fonticon instead of span

This commit is contained in:
Jan Prochazka
2020-11-10 17:34:00 +01:00
parent 1169e23997
commit 1c2dedfef3
20 changed files with 77 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from './icons';
const TargetStyled = styled.div` const TargetStyled = styled.div`
position: fixed; position: fixed;
@@ -41,7 +42,7 @@ export default function DragAndDropFileTarget({ isDragActive, inputProps }) {
<TargetStyled> <TargetStyled>
<InfoBox> <InfoBox>
<IconWrapper> <IconWrapper>
<span className="mdi mdi-cloud-upload" /> <FontIcon icon="icon cloud-upload" />
</IconWrapper> </IconWrapper>
<TitleWrapper>Drop the files to upload to DbGate</TitleWrapper> <TitleWrapper>Drop the files to upload to DbGate</TitleWrapper>
<InfoWrapper>Supported file types: csv, MS Excel, json-lines</InfoWrapper> <InfoWrapper>Supported file types: csv, MS Excel, json-lines</InfoWrapper>

View File

@@ -7,6 +7,7 @@ import { DropDownMenuItem, DropDownMenuDivider } from './modals/DropDownMenu';
import { useOpenedTabs, useSetOpenedTabs, useCurrentDatabase, useSetCurrentDatabase } from './utility/globalState'; import { useOpenedTabs, useSetOpenedTabs, useCurrentDatabase, useSetCurrentDatabase } from './utility/globalState';
import { showMenu } from './modals/DropDownMenu'; import { showMenu } from './modals/DropDownMenu';
import { getConnectionInfo } from './utility/metadataLoaders'; import { getConnectionInfo } from './utility/metadataLoaders';
import { FontIcon } from './icons';
// const files = [ // const files = [
// { name: 'app.js' }, // { name: 'app.js' },
@@ -116,9 +117,9 @@ function getTabDbKey(tab) {
} }
function getDbIcon(key) { function getDbIcon(key) {
if (key.startsWith('database://')) return 'mdi mdi-database'; if (key.startsWith('database://')) return 'icon database';
if (key.startsWith('archive://')) return 'mdi mdi-archive'; if (key.startsWith('archive://')) return 'icon archive';
return 'mdi mdi-file'; return 'icon file';
} }
export default function TabsPanel() { export default function TabsPanel() {
@@ -252,7 +253,7 @@ export default function TabsPanel() {
selected={tabsByDb[dbKey][0].tabDbKey == currentDbKey} selected={tabsByDb[dbKey][0].tabDbKey == currentDbKey}
onClick={() => handleSetDb(tabsByDb[dbKey][0].props)} onClick={() => handleSetDb(tabsByDb[dbKey][0].props)}
> >
<span className={getDbIcon(dbKey)} /> {tabsByDb[dbKey][0].tabDbName} <FontIcon icon={getDbIcon(dbKey)} /> {tabsByDb[dbKey][0].tabDbName}
</DbNameWrapper> </DbNameWrapper>
<DbGroupHandler> <DbGroupHandler>
{_.sortBy(tabsByDb[dbKey], 'title').map((tab) => ( {_.sortBy(tabsByDb[dbKey], 'title').map((tab) => (
@@ -264,7 +265,7 @@ export default function TabsPanel() {
onMouseUp={(e) => handleMouseUp(e, tab.tabid)} onMouseUp={(e) => handleMouseUp(e, tab.tabid)}
onContextMenu={(e) => handleContextMenu(e, tab.tabid, tab.props)} onContextMenu={(e) => handleContextMenu(e, tab.tabid, tab.props)}
> >
{<span className={tab.busy ? 'mdi mdi-loading mdi-spin' : tab.icon} />} {<FontIcon icon={tab.busy ? 'mdi mdi-loading mdi-spin' : tab.icon} />}
<FileNameWrapper>{tab.title}</FileNameWrapper> <FileNameWrapper>{tab.title}</FileNameWrapper>
<CloseButton <CloseButton
className="mdi mdi-close tabCloseButton" className="mdi mdi-close tabCloseButton"

View File

@@ -3,6 +3,7 @@
import _ from 'lodash'; import _ from 'lodash';
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
import { showMenu } from '../modals/DropDownMenu'; import { showMenu } from '../modals/DropDownMenu';
import { useSetOpenedTabs, useAppObjectParams } from '../utility/globalState'; import { useSetOpenedTabs, useAppObjectParams } from '../utility/globalState';
@@ -67,11 +68,11 @@ export function AppObjectCore({
{...other} {...other}
> >
{prefix} {prefix}
<IconWrap>{isBusy ? <span className="mdi mdi-loading mdi-spin"></span> : <span className={icon} />}</IconWrap> <IconWrap>{isBusy ? <FontIcon icon="mdi mdi-loading mdi-spin" /> : <FontIcon icon={icon} />}</IconWrap>
{title} {title}
{statusIcon && ( {statusIcon && (
<StatusIconWrap> <StatusIconWrap>
<span className={statusIcon} title={statusTitle} /> <FontIcon icon={statusIcon} title={statusTitle} />
</StatusIconWrap> </StatusIconWrap>
)} )}
</Component> </Component>

View File

@@ -7,6 +7,7 @@ import { useSplitterDrag } from '../widgets/Splitter';
import { isTypeDateTime } from '@dbgate/tools'; import { isTypeDateTime } from '@dbgate/tools';
import { openDatabaseObjectDetail } from '../appobj/databaseObjectAppObject'; import { openDatabaseObjectDetail } from '../appobj/databaseObjectAppObject';
import { useSetOpenedTabs } from '../utility/globalState'; import { useSetOpenedTabs } from '../utility/globalState';
import { FontIcon } from '../icons';
const HeaderDiv = styled.div` const HeaderDiv = styled.div`
display: flex; display: flex;
@@ -85,12 +86,12 @@ export default function ColumnHeaderControl({
<ColumnLabel {...column} /> <ColumnLabel {...column} />
{order == 'ASC' && ( {order == 'ASC' && (
<IconWrapper> <IconWrapper>
<span className="mdi mdi-sort-alphabetical-ascending color-green" /> <FontIcon icon="mdi mdi-sort-alphabetical-ascending color-green" />
</IconWrapper> </IconWrapper>
)} )}
{order == 'DESC' && ( {order == 'DESC' && (
<IconWrapper> <IconWrapper>
<span className="mdi mdi-sort-alphabetical-descending color-green" /> <FontIcon icon="mdi mdi-sort-alphabetical-descending color-green" />
</IconWrapper> </IconWrapper>
)} )}
</LabelDiv> </LabelDiv>

View File

@@ -2,6 +2,7 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
const Label = styled.span` const Label = styled.span`
font-weight: ${props => (props.notNull ? 'bold' : 'normal')}; font-weight: ${props => (props.notNull ? 'bold' : 'normal')};
@@ -15,7 +16,7 @@ export default function ColumnLabel(column) {
if (column.foreignKey) icon = 'mdi mdi-key-link'; if (column.foreignKey) icon = 'mdi mdi-key-link';
return ( return (
<Label {...column}> <Label {...column}>
{icon ? <span className={icon} /> : null} {column.headerText || column.columnName} {icon ? <FontIcon icon={icon} /> : null} {column.headerText || column.columnName}
</Label> </Label>
); );
} }

View File

@@ -8,6 +8,7 @@ import InlineButton from '../widgets/InlineButton';
import useShowModal from '../modals/showModal'; import useShowModal from '../modals/showModal';
import FilterMultipleValuesModal from '../modals/FilterMultipleValuesModal'; import FilterMultipleValuesModal from '../modals/FilterMultipleValuesModal';
import SetFilterModal from '../modals/SetFilterModal'; import SetFilterModal from '../modals/SetFilterModal';
import { FontIcon } from '../icons';
// import { $ } from '../../Utility/jquery'; // import { $ } from '../../Utility/jquery';
// import autobind from 'autobind-decorator'; // import autobind from 'autobind-decorator';
// import * as React from 'react'; // import * as React from 'react';
@@ -291,7 +292,7 @@ export default function DataFilterControl({
autocomplete="off" autocomplete="off"
/> />
<InlineButton buttonRef={buttonRef} onClick={handleShowMenu} square> <InlineButton buttonRef={buttonRef} onClick={handleShowMenu} square>
<span className="mdi mdi-filter" /> <FontIcon icon="mdi mdi-filter" />
</InlineButton> </InlineButton>
</FilterDiv> </FilterDiv>
); );

View File

@@ -28,6 +28,7 @@ import LoadingInfo from '../widgets/LoadingInfo';
import ErrorInfo from '../widgets/ErrorInfo'; import ErrorInfo from '../widgets/ErrorInfo';
import { openNewTab } from '../utility/common'; import { openNewTab } from '../utility/common';
import { useSetOpenedTabs } from '../utility/globalState'; import { useSetOpenedTabs } from '../utility/globalState';
import { FontIcon } from '../icons';
const GridContainer = styled.div` const GridContainer = styled.div`
position: absolute; position: absolute;
@@ -971,7 +972,7 @@ export default function DataGridCore(props) {
> >
{filterCount > 0 && ( {filterCount > 0 && (
<InlineButton onClick={handleClearFilters} square> <InlineButton onClick={handleClearFilters} square>
<span className="mdi mdi-filter-off" /> <FontIcon icon="mdi mdi-filter-off" />
</InlineButton> </InlineButton>
)} )}
</TableHeaderCell> </TableHeaderCell>

View File

@@ -2,6 +2,7 @@ import React from 'react';
import ToolbarButton from '../widgets/ToolbarButton'; import ToolbarButton from '../widgets/ToolbarButton';
import styled from 'styled-components'; import styled from 'styled-components';
import theme from '../theme'; import theme from '../theme';
import { FontIcon } from '../icons';
const Container = styled.div` const Container = styled.div`
display: flex; display: flex;
@@ -29,7 +30,7 @@ export default function ReferenceHeader({ reference, onClose }) {
return ( return (
<Container> <Container>
<Header> <Header>
<span className="mdi mdi-link-box" /> <FontIcon icon="mdi mdi-link-box" />
<HeaderText> <HeaderText>
{reference.pureName} [{reference.columns.map((x) => x.refName).join(', ')}] = master [ {reference.pureName} [{reference.columns.map((x) => x.refName).join(', ')}] = master [
{reference.columns.map((x) => x.baseName).join(', ')}] {reference.columns.map((x) => x.baseName).join(', ')}]

View File

@@ -3,6 +3,7 @@ import styled from 'styled-components';
import { ManagerInnerContainer } from './ManagerStyles'; import { ManagerInnerContainer } from './ManagerStyles';
import SearchInput from '../widgets/SearchInput'; import SearchInput from '../widgets/SearchInput';
import { filterName } from '@dbgate/datalib'; import { filterName } from '@dbgate/datalib';
import { FontIcon } from '../icons';
const SearchBoxWrapper = styled.div` const SearchBoxWrapper = styled.div`
display: flex; display: flex;
@@ -33,7 +34,7 @@ const NameContainer = styled.div`
function ManagerRow({ tableName, columns, icon, onClick }) { function ManagerRow({ tableName, columns, icon, onClick }) {
return ( return (
<LinkContainer onClick={onClick}> <LinkContainer onClick={onClick}>
<span className={icon} /> <FontIcon icon={icon} />
<NameContainer> <NameContainer>
{tableName} ({columns.map((x) => x.columnName).join(', ')}) {tableName} ({columns.map((x) => x.columnName).join(', ')})
</NameContainer> </NameContainer>

View File

@@ -8,6 +8,7 @@ import MacroParameters from './MacroParameters';
import { WidgetTitle } from '../widgets/WidgetStyles'; import { WidgetTitle } from '../widgets/WidgetStyles';
import { FormButton } from '../utility/forms'; import { FormButton } from '../utility/forms';
import FormStyledButton from '../widgets/FormStyledButton'; import FormStyledButton from '../widgets/FormStyledButton';
import { FontIcon } from '../icons';
const Container = styled.div` const Container = styled.div`
display: flex; display: flex;
@@ -62,7 +63,7 @@ function MacroHeader({ selectedMacro, setSelectedMacro, onExecute }) {
return ( return (
<Container> <Container>
<Header> <Header>
<span className="mdi mdi-hammer-wrench" /> <FontIcon icon="mdi mdi-hammer-wrench" />
<HeaderText>{selectedMacro.title}</HeaderText> <HeaderText>{selectedMacro.title}</HeaderText>
</Header> </Header>
<Buttons> <Buttons>

View File

@@ -1,14 +1,30 @@
import React from 'react'; import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
export function ExpandIcon({ isBlank = false, isExpanded = false, className = '', ...other }) { const iconNames = {
if (isBlank) { 'icon minus-box': 'mdi mdi-minus-box-outline',
return <span className={`mdi mdi-minus-box-outline icon-invisible ${className}`} {...other} />; 'icon plus-box': 'mdi mdi-plus-box-outline',
'icon invisible-box': 'mdi mdi-minus-box-outline icon-invisible',
'icon cloud-upload': 'mdi mdi-cloud-upload',
'icon database': 'mdi mdi-database',
'icon archive': 'mdi mdi-archive',
'icon file': 'mdi mdi-file',
};
export function FontIcon({ icon, className = '', ...other }) {
if (!icon) return null;
let cls = icon;
if (icon.startsWith('icon ')) {
cls = iconNames[icon];
if (!cls) return null;
} }
return ( return <span className={`${cls} ${className}`} {...other} />;
<span }
className={`${isExpanded ? 'mdi mdi-minus-box-outline' : 'mdi mdi-plus-box-outline'} ${className}`}
{...other} export function ExpandIcon({ isBlank = false, isExpanded = false, ...other }) {
/> if (isBlank) {
); return <FontIcon icon="icon invisible-box" {...other} />;
}
return <FontIcon icon={isExpanded ? 'icon minus-box' : 'icon plus-box'} {...other} />;
} }

View File

@@ -23,6 +23,7 @@ import axios from '../utility/axios';
import LoadingInfo from '../widgets/LoadingInfo'; import LoadingInfo from '../widgets/LoadingInfo';
import SqlEditor from '../sqleditor/SqlEditor'; import SqlEditor from '../sqleditor/SqlEditor';
import { useUploadsProvider } from '../utility/UploadsProvider'; import { useUploadsProvider } from '../utility/UploadsProvider';
import { FontIcon } from '../icons';
const Container = styled.div` const Container = styled.div`
// max-height: 50vh; // max-height: 50vh;
@@ -294,7 +295,7 @@ function SourceName({ name }) {
<SourceNameWrapper> <SourceNameWrapper>
<div>{name}</div> <div>{name}</div>
<TrashWrapper onClick={handleDelete}> <TrashWrapper onClick={handleDelete}>
<span className="mdi mdi-delete" /> <FontIcon icon="mdi mdi-delete" />
</TrashWrapper> </TrashWrapper>
</SourceNameWrapper> </SourceNameWrapper>
); );
@@ -352,7 +353,7 @@ export default function ImportExportConfigurator({ uploadedFile = undefined }) {
engine={sourceEngine} engine={sourceEngine}
/> />
<ArrowWrapper> <ArrowWrapper>
<span className="mdi mdi-arrow-right" /> <FontIcon icon="mdi mdi-arrow-right" />
</ArrowWrapper> </ArrowWrapper>
<SourceTargetConfig <SourceTargetConfig
direction="target" direction="target"

View File

@@ -5,6 +5,7 @@ import styled from 'styled-components';
import ModalHeader from './ModalHeader'; import ModalHeader from './ModalHeader';
import ModalFooter from './ModalFooter'; import ModalFooter from './ModalFooter';
import ModalContent from './ModalContent'; import ModalContent from './ModalContent';
import { FontIcon } from '../icons';
const Wrapper = styled.div` const Wrapper = styled.div`
display:flex display:flex
@@ -23,7 +24,7 @@ export default function ErrorMessageModal({ modalState, title = 'Error', message
<ModalContent> <ModalContent>
<Wrapper> <Wrapper>
<IconWrapper> <IconWrapper>
<span className="mdi mdi-close-circle color-red" /> <FontIcon icon="mdi mdi-close-circle color-red" />
</IconWrapper> </IconWrapper>
{message} {message}
</Wrapper> </Wrapper>

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
const Wrapper = styled.div` const Wrapper = styled.div`
font-size: 15pt; font-size: 15pt;
@@ -23,7 +24,7 @@ export default function ModalHeader({ children, modalState }) {
<Wrapper> <Wrapper>
<div>{children}</div> <div>{children}</div>
<CloseWrapper onClick={modalState.close}> <CloseWrapper onClick={modalState.close}>
<span className="mdi mdi-close" /> <FontIcon icon="mdi mdi-close" />
</CloseWrapper> </CloseWrapper>
</Wrapper> </Wrapper>
); );

View File

@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { FontIcon } from '../icons';
import { showMenu } from '../modals/DropDownMenu'; import { showMenu } from '../modals/DropDownMenu';
import InlineButton from './InlineButton'; import InlineButton from './InlineButton';
@@ -12,7 +13,7 @@ export default function DropDownButton({ children }) {
return ( return (
<InlineButton buttonRef={buttonRef} onClick={handleShowMenu} square> <InlineButton buttonRef={buttonRef} onClick={handleShowMenu} square>
<span className="mdi mdi-chevron-down" /> <FontIcon icon="mdi mdi-chevron-down" />
</InlineButton> </InlineButton>
); );
} }

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
const Container = styled.div` const Container = styled.div`
display: flex; display: flex;
@@ -22,7 +23,7 @@ export default function ErrorInfo({ message, icon = 'mdi mdi-close-circle color-
if (isSmall) { if (isSmall) {
return ( return (
<ContainerSmall> <ContainerSmall>
<span className={icon} /> <FontIcon icon={icon} />
{message} {message}
</ContainerSmall> </ContainerSmall>
); );
@@ -30,7 +31,7 @@ export default function ErrorInfo({ message, icon = 'mdi mdi-close-circle color-
return ( return (
<Container> <Container>
<Icon> <Icon>
<span className={icon} /> <FontIcon icon={icon} />
</Icon> </Icon>
{message} {message}
</Container> </Container>

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
const Container = styled.div` const Container = styled.div`
display: flex; display: flex;
@@ -33,7 +34,7 @@ export default function LoadingInfo({ message, wrapper = false }) {
const core = ( const core = (
<Container> <Container>
<Spinner> <Spinner>
<span className="mdi mdi-loading mdi-spin" /> <FontIcon icon="mdi mdi-loading mdi-spin" />
</Spinner> </Spinner>
{message} {message}
</Container> </Container>

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
import { useCurrentDatabase } from '../utility/globalState'; import { useCurrentDatabase } from '../utility/globalState';
import { useDatabaseStatus } from '../utility/metadataLoaders'; import { useDatabaseStatus } from '../utility/metadataLoaders';
@@ -24,18 +25,18 @@ export default function StatusBar() {
<Container> <Container>
{name && ( {name && (
<Item> <Item>
<span className="mdi mdi-database" /> {name} <FontIcon icon="mdi mdi-database" /> {name}
</Item> </Item>
)} )}
{(displayName || server) && ( {(displayName || server) && (
<Item> <Item>
<span className='mdi mdi-server'/> {displayName || server} <FontIcon icon='mdi mdi-server'/> {displayName || server}
</Item> </Item>
)} )}
{user && ( {user && (
<Item> <Item>
<span className="mdi mdi-account" /> {user} <FontIcon icon="mdi mdi-account" /> {user}
</Item> </Item>
)} )}
@@ -43,17 +44,17 @@ export default function StatusBar() {
<Item> <Item>
{status.name == 'pending' && ( {status.name == 'pending' && (
<> <>
<span className="mdi mdi-loading mdi-spin" /> Loading <FontIcon icon="mdi mdi-loading mdi-spin" /> Loading
</> </>
)} )}
{status.name == 'ok' && ( {status.name == 'ok' && (
<> <>
<span className="mdi mdi-check-circle color-on-statusbar-green" /> Connected <FontIcon icon="mdi mdi-check-circle color-on-statusbar-green" /> Connected
</> </>
)} )}
{status.name == 'error' && ( {status.name == 'error' && (
<> <>
<span className="mdi mdi-close-circle color-red" /> Error <FontIcon icon="mdi mdi-close-circle color-red" /> Error
</> </>
)} )}
</Item> </Item>
@@ -61,7 +62,7 @@ export default function StatusBar() {
{!connection && ( {!connection && (
<Item> <Item>
<> <>
<span className="mdi mdi-lan-disconnect" /> Not connected <FontIcon icon="mdi mdi-lan-disconnect" /> Not connected
</> </>
</Item> </Item>
)} )}

View File

@@ -1,6 +1,7 @@
// @ts-nocheck // @ts-nocheck
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { FontIcon } from '../icons';
import theme from '../theme'; import theme from '../theme';
const ButtonDiv = styled.div` const ButtonDiv = styled.div`
@@ -53,7 +54,7 @@ export default function ToolbarButton({ children, onClick, icon = undefined, dis
<ButtonDivInner patchY={patchY}> <ButtonDivInner patchY={patchY}>
{icon && ( {icon && (
<StyledIconSpan disabled={disabled}> <StyledIconSpan disabled={disabled}>
<span className={icon} /> <FontIcon icon={icon} />
</StyledIconSpan> </StyledIconSpan>
)} )}
{children} {children}

View File

@@ -2,6 +2,7 @@ import React from 'react';
import theme from '../theme'; import theme from '../theme';
import styled from 'styled-components'; import styled from 'styled-components';
import { useCurrentWidget, useSetCurrentWidget } from '../utility/globalState'; import { useCurrentWidget, useSetCurrentWidget } from '../utility/globalState';
import { FontIcon } from '../icons';
const IconWrapper = styled.div` const IconWrapper = styled.div`
color: ${theme.widgetMenu.iconFontColor}; color: ${theme.widgetMenu.iconFontColor};
@@ -62,7 +63,7 @@ export default function WidgetIconPanel() {
onClick={() => setCurrentWidget(name === currentWidget ? null : name)} onClick={() => setCurrentWidget(name === currentWidget ? null : name)}
title={title} title={title}
> >
<span className={icon} /> <FontIcon icon={icon} />
</IconWrapper> </IconWrapper>
))} ))}
</> </>