feat: text resource renderer
This commit is contained in:
parent
cbe2c18140
commit
66103e63ff
|
@ -1,6 +1,7 @@
|
|||
import flatten from 'lodash.flatten';
|
||||
|
||||
import BinaryRenderer from '../binary-renderer';
|
||||
import TextResourceRenderer from '../text-renderer';
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
|
@ -12,5 +13,8 @@ export default {
|
|||
};
|
||||
latus.set('%resource-renderers', Renderer);
|
||||
},
|
||||
'@persea/core/resource-renderers': () => [
|
||||
TextResourceRenderer,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
27
packages/core/src/text-renderer/index.jsx
Normal file
27
packages/core/src/text-renderer/index.jsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import './index.scss';
|
||||
|
||||
import {PropTypes, React} from '@latus/react';
|
||||
|
||||
const TextRendererComponent = ({buffer}) => (
|
||||
<div className="text-renderer">{buffer.toString()}</div>
|
||||
);
|
||||
|
||||
TextRendererComponent.propTypes = {
|
||||
buffer: PropTypes.shape({
|
||||
toString: PropTypes.func,
|
||||
}).isRequired,
|
||||
};
|
||||
|
||||
export default class TextResourceRenderer {
|
||||
|
||||
static Component({buffer}) {
|
||||
return (
|
||||
<TextRendererComponent buffer={buffer} />
|
||||
);
|
||||
}
|
||||
|
||||
static get matcher() {
|
||||
return /\.txt$/;
|
||||
}
|
||||
|
||||
}
|
3
packages/core/src/text-renderer/index.scss
Normal file
3
packages/core/src/text-renderer/index.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
.text-renderer {
|
||||
font-family: monospace;
|
||||
}
|
Loading…
Reference in New Issue
Block a user