0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-27 07:23:09 +00:00

update component/key names

This commit is contained in:
Charlie Humphreys
2023-07-15 00:14:50 -05:00
parent 18c94f95f3
commit 9d6a9c4ebf
6 changed files with 18 additions and 18 deletions

View File

@@ -6,9 +6,9 @@ export const HINT_TYPE = {
}; };
export const SNIPPET_TYPE = { export const SNIPPET_TYPE = {
DEFAULT : 0, BLOCK : 0,
INLINE_SNIPPET : 1, INLINE : 1,
IMAGE : 2, INJECTOR : 2,
}; };
export const FIELD_TYPE = { export const FIELD_TYPE = {
@@ -18,9 +18,9 @@ export const FIELD_TYPE = {
export const PATTERNS = { export const PATTERNS = {
snippet : { snippet : {
[SNIPPET_TYPE.DEFAULT] : (name)=>new RegExp(`^{{${name}(?:[^a-zA-Z].*)?`), [SNIPPET_TYPE.BLOCK] : (name)=>new RegExp(`^{{${name}(?:[^a-zA-Z].*)?`),
[SNIPPET_TYPE.INLINE_SNIPPET] : (name)=>new RegExp(`{{${name}`), [SNIPPET_TYPE.INLINE] : (name)=>new RegExp(`{{${name}`),
[SNIPPET_TYPE.IMAGE] : ()=>new RegExp(`^\\!\\[(?:[a-zA-Z -]+)?\\]\\(.*\\).*{[a-zA-Z0-9:, "'-]+}$`), [SNIPPET_TYPE.INJECTOR] : ()=>new RegExp(`^\\!\\[(?:[a-zA-Z -]+)?\\]\\(.*\\).*{[a-zA-Z0-9:, "'-]+}$`),
}, },
field : { field : {
[FIELD_TYPE.TEXT] : (name)=>new RegExp(`[{,;](${name}):("[^},;"]*"|[^},;]*)`), [FIELD_TYPE.TEXT] : (name)=>new RegExp(`[{,;](${name}):("[^},;"]*"|[^},;]*)`),

View File

@@ -1,7 +1,7 @@
const Field = require('./field/field.jsx'); const Text = require('./text/text.jsx');
const Checkbox = require('./checkbox/checkbox.jsx'); const Checkbox = require('./checkbox/checkbox.jsx');
module.exports = { module.exports = {
Field : Field, Text : Text,
Checkbox : Checkbox, Checkbox : Checkbox,
}; };

View File

@@ -1,4 +1,4 @@
require('./field.less'); require('./text.less');
const React = require('react'); const React = require('react');
const createClass = require('create-react-class'); const createClass = require('create-react-class');
const _ = require('lodash'); const _ = require('lodash');
@@ -10,7 +10,7 @@ const STYLE_FN = (value)=>({
width : `calc(${value?.length ?? 0}ch + ${value?.length ? `${DEFAULT_WIDTH} / 2` : DEFAULT_WIDTH})` width : `calc(${value?.length ?? 0}ch + ${value?.length ? `${DEFAULT_WIDTH} / 2` : DEFAULT_WIDTH})`
}); });
const Field = createClass({ const Text = createClass({
fieldRef : {}, fieldRef : {},
getDefaultProps : function() { getDefaultProps : function() {
@@ -157,4 +157,4 @@ const Field = createClass({
} }
}); });
module.exports = Field; module.exports = Text;

View File

@@ -2,7 +2,7 @@ const React = require('react');
const ReactDOM = require('react-dom'); const ReactDOM = require('react-dom');
const { PATTERNS, FIELD_TYPE, HINT_TYPE, UNITS } = require('./widget-elements/constants'); const { PATTERNS, FIELD_TYPE, HINT_TYPE, UNITS } = require('./widget-elements/constants');
require('./widget-elements/hints/hints.jsx'); require('./widget-elements/hints/hints.jsx');
const { Field, Checkbox } = require('./widget-elements'); const { Text, Checkbox } = require('./widget-elements');
// See https://codemirror.net/5/addon/hint/css-hint.js for code reference // See https://codemirror.net/5/addon/hint/css-hint.js for code reference
const pseudoClasses = { 'active' : 1, 'after' : 1, 'before' : 1, 'checked' : 1, 'default' : 1, const pseudoClasses = { 'active' : 1, 'after' : 1, 'before' : 1, 'checked' : 1, 'default' : 1,
@@ -87,7 +87,7 @@ module.exports = function(CodeMirror, widgets, cm, setHints) {
if(field.type === FIELD_TYPE.CHECKBOX) { if(field.type === FIELD_TYPE.CHECKBOX) {
return <Checkbox key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} n={n} prefix={widget.name} value={field.name}/>; return <Checkbox key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} n={n} prefix={widget.name} value={field.name}/>;
} else if(field.type === FIELD_TYPE.TEXT) { } else if(field.type === FIELD_TYPE.TEXT) {
return <Field key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>; return <Text key={genKey(widget.name, n, field.name)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>;
} else { } else {
return null; return null;
} }
@@ -101,7 +101,7 @@ module.exports = function(CodeMirror, widgets, cm, setHints) {
increment : 5, increment : 5,
hints : true, hints : true,
}; };
return <Field key={genKey(widget.name, n, style)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>; return <Text key={genKey(widget.name, n, style)} cm={cm} CodeMirror={CodeMirror} field={field} n={n} text={text} setHints={(f, h)=>setHints(h, f)} getStyleHints={getStyleHints}/>;
}).filter(Boolean); }).filter(Boolean);
ReactDOM.render(<React.Fragment> ReactDOM.render(<React.Fragment>

View File

@@ -2,7 +2,7 @@ const { SNIPPET_TYPE, FIELD_TYPE } = require('../../../shared/naturalcrit/codeEd
module.exports = [{ module.exports = [{
name : 'monster', name : 'monster',
type : SNIPPET_TYPE.DEFAULT, type : SNIPPET_TYPE.BLOCK,
fields : [{ fields : [{
name : 'frame', name : 'frame',
type : FIELD_TYPE.CHECKBOX type : FIELD_TYPE.CHECKBOX
@@ -12,7 +12,7 @@ module.exports = [{
}] }]
}, { }, {
name : 'classTable', name : 'classTable',
type : SNIPPET_TYPE.DEFAULT, type : SNIPPET_TYPE.BLOCK,
fields : [{ fields : [{
name : 'frame', name : 'frame',
type : FIELD_TYPE.CHECKBOX type : FIELD_TYPE.CHECKBOX
@@ -25,11 +25,11 @@ module.exports = [{
}] }]
}, { }, {
name : 'image', name : 'image',
type : SNIPPET_TYPE.IMAGE, type : SNIPPET_TYPE.INJECTOR,
fields : [] fields : []
}, { }, {
name : 'artist', name : 'artist',
type : SNIPPET_TYPE.DEFAULT, type : SNIPPET_TYPE.BLOCK,
fields : [{ fields : [{
name : 'top', name : 'top',
type : FIELD_TYPE.TEXT, type : FIELD_TYPE.TEXT,