0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-27 13:53: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 = {
DEFAULT : 0,
INLINE_SNIPPET : 1,
IMAGE : 2,
BLOCK : 0,
INLINE : 1,
INJECTOR : 2,
};
export const FIELD_TYPE = {
@@ -18,9 +18,9 @@ export const FIELD_TYPE = {
export const PATTERNS = {
snippet : {
[SNIPPET_TYPE.DEFAULT] : (name)=>new RegExp(`^{{${name}(?:[^a-zA-Z].*)?`),
[SNIPPET_TYPE.INLINE_SNIPPET] : (name)=>new RegExp(`{{${name}`),
[SNIPPET_TYPE.IMAGE] : ()=>new RegExp(`^\\!\\[(?:[a-zA-Z -]+)?\\]\\(.*\\).*{[a-zA-Z0-9:, "'-]+}$`),
[SNIPPET_TYPE.BLOCK] : (name)=>new RegExp(`^{{${name}(?:[^a-zA-Z].*)?`),
[SNIPPET_TYPE.INLINE] : (name)=>new RegExp(`{{${name}`),
[SNIPPET_TYPE.INJECTOR] : ()=>new RegExp(`^\\!\\[(?:[a-zA-Z -]+)?\\]\\(.*\\).*{[a-zA-Z0-9:, "'-]+}$`),
},
field : {
[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');
module.exports = {
Field : Field,
Text : Text,
Checkbox : Checkbox,
};

View File

@@ -1,4 +1,4 @@
require('./field.less');
require('./text.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
@@ -10,7 +10,7 @@ const STYLE_FN = (value)=>({
width : `calc(${value?.length ?? 0}ch + ${value?.length ? `${DEFAULT_WIDTH} / 2` : DEFAULT_WIDTH})`
});
const Field = createClass({
const Text = createClass({
fieldRef : {},
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 { PATTERNS, FIELD_TYPE, HINT_TYPE, UNITS } = require('./widget-elements/constants');
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
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) {
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) {
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 {
return null;
}
@@ -101,7 +101,7 @@ module.exports = function(CodeMirror, widgets, cm, setHints) {
increment : 5,
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);
ReactDOM.render(<React.Fragment>

View File

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