Skip to content
Snippets Groups Projects
Commit eb45b449 authored by vkovtun's avatar vkovtun
Browse files

SSDM-13579: Put icon styles in the component itself.

parent bedcfca4
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -19,10 +19,6 @@ const styles = (theme) => ({ ...@@ -19,10 +19,6 @@ const styles = (theme) => ({
backgroundColor: '#0000000a' backgroundColor: '#0000000a'
}, },
}, },
icon: {
verticalAlign: 'middle',
fontSize: '6rem'
},
}) })
class GridViewItem extends React.Component { class GridViewItem extends React.Component {
...@@ -33,7 +29,7 @@ class GridViewItem extends React.Component { ...@@ -33,7 +29,7 @@ class GridViewItem extends React.Component {
return ( return (
<Grid item component={Card} variant="outlined" className={classes.cell}> <Grid item component={Card} variant="outlined" className={classes.cell}>
<CardMedia> <CardMedia>
<ItemIcon classes={classes} file={file} configuration={configuration} /> <ItemIcon file={file} configuration={configuration} />
</CardMedia> </CardMedia>
<CardContent> <CardContent>
{file.name} {file.name}
......
...@@ -15,13 +15,20 @@ ...@@ -15,13 +15,20 @@
* *
*/ */
import React from "react"; import React from 'react'
import FolderIcon from "@material-ui/icons/FolderOpen.js"; import FolderIcon from '@material-ui/icons/FolderOpen.js'
import FileIcon from "@material-ui/icons/InsertDriveFileOutlined.js"; import FileIcon from '@material-ui/icons/InsertDriveFileOutlined.js'
import autoBind from "auto-bind"; import autoBind from 'auto-bind'
import { withStyles } from '@material-ui/core/styles'
const styles = (theme) => ({
icon: {
verticalAlign: 'middle',
fontSize: '6rem'
}
})
class ItemIcon extends React.Component { class ItemIcon extends React.Component {
constructor(props, context) { constructor(props, context) {
super(props, context) super(props, context)
autoBind(this) autoBind(this)
...@@ -29,8 +36,8 @@ class ItemIcon extends React.Component { ...@@ -29,8 +36,8 @@ class ItemIcon extends React.Component {
const { configuration } = this.props const { configuration } = this.props
this.extensionToIconType = new Map( this.extensionToIconType = new Map(
configuration.flatMap( configuration.flatMap(configObject =>
(configObject) => configObject.extensions.map(extension => [extension, configObject.icon]) configObject.extensions.map(extension => [extension, configObject.icon])
) )
) )
} }
...@@ -41,11 +48,16 @@ class ItemIcon extends React.Component { ...@@ -41,11 +48,16 @@ class ItemIcon extends React.Component {
if (file.folder) { if (file.folder) {
return <FolderIcon className={classes.icon} /> return <FolderIcon className={classes.icon} />
} else { } else {
const iconType = this.extensionToIconType.get(file.name.substring(file.name.lastIndexOf(".") + 1)) const iconType = this.extensionToIconType.get(
return iconType ? React.createElement(iconType, { className: classes.icon }) : <FileIcon className={classes.icon} /> file.name.substring(file.name.lastIndexOf('.') + 1)
)
return iconType ? (
React.createElement(iconType, { className: classes.icon })
) : (
<FileIcon className={classes.icon} />
)
} }
} }
} }
export default ItemIcon export default withStyles(styles)(ItemIcon)
\ No newline at end of file
...@@ -39,7 +39,6 @@ const styles = theme => ({ ...@@ -39,7 +39,6 @@ const styles = theme => ({
textAlign: 'right' textAlign: 'right'
}, },
icon: { icon: {
verticalAlign: 'middle',
fontSize: '2.5rem' fontSize: '2.5rem'
}, },
text: { text: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment