1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 19:44:21 +00:00
This commit is contained in:
Steffo 2020-06-21 15:04:56 +02:00
parent ba939a23a7
commit 2cea4fe992
Signed by: steffo
GPG key ID: 896A80F55F7C97F0
8 changed files with 85 additions and 1 deletions

View file

@ -1,7 +1,7 @@
{
"private": false,
"name": "bluelib",
"version": "0.11.4",
"version": "0.11.5",
"license": "AGPL-3.0-or-later",
"source": "src/index.js",
"main": "dist/index.js",

View file

@ -0,0 +1,11 @@
import style from './HInput.less';
export default function (props) {
return (
<label className={style.label}>
<div className={style.text}>{this.props.label}</div>
<input className={style.input} type={this.props.type} value={this.props.value}
onChange={this.props.onChange} disabled={this.props.disabled} name={this.props.name}/>
</label>
);
}

View file

@ -0,0 +1,21 @@
@import "../../styles/constants.less";
.label {
width: 100%;
display: flex;
align-items: center;
margin-top: 2px;
margin-bottom: 2px;
}
.text {
flex-grow: 1;
max-width: 160px;
text-align: right;
margin-right: 4px;
}
.input {
margin-left: 4px;
flex-grow: 2;
}

View file

@ -7,6 +7,7 @@ import TablePanel from "./components/Elements/TablePanel";
import Timer from "./components/Elements/Timer";
import Todo from "./components/Elements/Todo";
import HInput from "./components/Layout/HInput";
import Split from "./components/Layout/Split";
import BLatex from "./components/Rendering/BLatex";
@ -28,6 +29,10 @@ import useRoyalnetInstanceValidator from "./hooks/useRoyalnetInstanceValidator";
import theme from "./styles/theme.less";
import concatClass from "./utils/concatClass";
import getEventValue from "./utils/getEventValue";
import isString from "./utils/isString";
import isValidDate from "./utils/isValidDate";
import stripTabs from "./utils/stripTabs";
import {royalnetApiRequest, RoyalnetApiError} from "./utils/royalnetApiRequest";
@ -41,7 +46,10 @@ export {
TablePanel,
Timer,
Todo,
HInput,
Split,
BLatex,
Code,
ILatex,
@ -49,14 +57,22 @@ export {
LatexDisplay,
Markdown,
PLatex,
LatexDefaultDisplay,
LatexDefaultInline,
LatexRenderColor,
RoyalnetInstanceUrl,
useFormValidator,
useRoyalnetData,
useRoyalnetInstanceValidator,
theme,
concatClass,
getEventValue,
isString,
isValidDate,
stripTabs,
royalnetApiRequest,
RoyalnetApiError,

25
src/utils/concatClass.js Normal file
View file

@ -0,0 +1,25 @@
export default function concatClass(...args) {
let result = "";
for(let i = 0; i < args.length; i++) {
let arg = args[i];
if(arg instanceof Array) {
result += concatClass(...arg)
}
else if(typeof arg == "string" || arg instanceof String) {
result += arg
}
else if(arg === null || arg === undefined) {
continue
}
else {
throw Error(`Invalid type '${typeof(arg)}' passed to extendableClasses, which only accepts Arrays and Strings.`)
}
if(i < args.length - 1) {
result += " "
}
}
return result
}

View file

@ -0,0 +1,5 @@
export default function(f) {
return function(event) {
return f(event.target.value)
}
}

3
src/utils/isString.js Normal file
View file

@ -0,0 +1,3 @@
export default function(s) {
return typeof s === "string" || s instanceof String
}

3
src/utils/isValidDate.js Normal file
View file

@ -0,0 +1,3 @@
export default function(d) {
return d instanceof Date && !isNaN(d.getTime())
}