Skip to content

Commit

Permalink
Merge pull request #40 from kawakamimoeki/reduce-duplication-of-c
Browse files Browse the repository at this point in the history
Reduce duplication of c
  • Loading branch information
kawakamimoeki authored Oct 17, 2024
2 parents 42447bb + 7e065fa commit ea35388
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 316 deletions.
160 changes: 160 additions & 0 deletions lib/clapton/javascripts/src/c-base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import { Clapton } from "components"

const bq = (...props: any[]) => {
return new Clapton.BlockQuote(...props)
}

const box = (...props: any[]) => {
return new Clapton.Box(...props)
}

const b = (...props: any[]) => {
return new Clapton.Bold(...props)
}

const button = (...props: any[]) => {
return new Clapton.Button(...props)
}

const check = (...props: any[]) => {
return new Clapton.Checkbox(props[0], props[1], props[2])
}

const code = (...props: any[]) => {
return new Clapton.Code(...props)
}

const datetime = (...props: any[]) => {
return new Clapton.DateTimeField(props[0], props[1], props[2])
}

const el = (...props: any[]) => {
return new Clapton.Element(props[0], props[1])
}

const embed = (...props: any[]) => {
return new Clapton.Embed(props[0])
}

const em = (...props: any[]) => {
return new Clapton.Emphasis(...props)
}

const form = (...props: any[]) => {
return new Clapton.Form(...props)
}

const h = (...props: any[]) => {
return new Clapton.Heading(props[0], props[1])
}

const img = (...props: any[]) => {
return new Clapton.Image(props[0], props[1], props[2])
}

const a = (...props: any[]) => {
return new Clapton.Link(props[0], props[1])
}

const li = (...props: any[]) => {
return new Clapton.ListItem(...props)
}

const ul = (...props: any[]) => {
return new Clapton.List(...props)
}

const ol = (...props: any[]) => {
return new Clapton.OrderedList(...props)
}

const p = (...props: any[]) => {
return new Clapton.Paragraph(...props)
}

const q = (...props: any[]) => {
return new Clapton.Quote(...props)
}

const radio = (...props: any[]) => {
return new Clapton.RadioButton(props[0], props[1], props[2])
}

const select = (...props: any[]) => {
return new Clapton.Select(props[0], props[1], props[2])
}

const span = (...props: any[]) => {
return new Clapton.Span(...props)
}

const textarea = (...props: any[]) => {
return new Clapton.TextArea(props[0], props[1], props[2])
}

const input = (...props: any[]) => {
return new Clapton.TextField(props[0], props[1], props[2])
}

const text = (...props: any[]) => {
return new Clapton.Text(props[0])
}

const c = (name: string, ...props: any[]) => {
switch (name) {
case "bq":
return bq(...props)
case "box":
return box(...props)
case "b":
return b(...props)
case "button":
return button(...props)
case "check":
return check(...props)
case "code":
return code(...props)
case "datetime":
return datetime(...props)
case "el":
return el(...props)
case "embed":
return embed(...props)
case "em":
return em(...props)
case "form":
return form(...props)
case "h":
return h(...props)
case "img":
return img(...props)
case "a":
return a(...props)
case "li":
return li(...props)
case "ul":
return ul(...props)
case "ol":
return ol(...props)
case "p":
return p(...props)
case "q":
return q(...props)
case "radio":
return radio(...props)
case "select":
return select(...props)
case "span":
return span(...props)
case "textarea":
return textarea(...props)
case "input":
return input(...props)
case "text":
return text(...props)
default:
return new Clapton.Component(...props)
}
}

export { c }
159 changes: 1 addition & 158 deletions lib/clapton/javascripts/src/c-for-test.ts
Original file line number Diff line number Diff line change
@@ -1,160 +1,3 @@
import { Clapton } from "components"

const bq = (...props: any[]) => {
return new Clapton.BlockQuote(...props)
}

const box = (...props: any[]) => {
return new Clapton.Box(...props)
}

const b = (...props: any[]) => {
return new Clapton.Bold(...props)
}

const button = (...props: any[]) => {
return new Clapton.Button(...props)
}

const check = (...props: any[]) => {
return new Clapton.Checkbox(props[0], props[1], props[2])
}

const code = (...props: any[]) => {
return new Clapton.Code(...props)
}

const datetime = (...props: any[]) => {
return new Clapton.DateTimeField(props[0], props[1], props[2])
}

const el = (...props: any[]) => {
return new Clapton.Element(props[0], props[1])
}

const embed = (...props: any[]) => {
return new Clapton.Embed(props[0])
}

const em = (...props: any[]) => {
return new Clapton.Emphasis(...props)
}

const form = (...props: any[]) => {
return new Clapton.Form(...props)
}

const h = (...props: any[]) => {
return new Clapton.Heading(props[0], props[1])
}

const img = (...props: any[]) => {
return new Clapton.Image(props[0], props[1], props[2])
}

const a = (...props: any[]) => {
return new Clapton.Link(props[0], props[1])
}

const li = (...props: any[]) => {
return new Clapton.ListItem(...props)
}

const ul = (...props: any[]) => {
return new Clapton.List(...props)
}

const ol = (...props: any[]) => {
return new Clapton.OrderedList(...props)
}

const p = (...props: any[]) => {
return new Clapton.Paragraph(...props)
}

const q = (...props: any[]) => {
return new Clapton.Quote(...props)
}

const radio = (...props: any[]) => {
return new Clapton.RadioButton(props[0], props[1], props[2])
}

const select = (...props: any[]) => {
return new Clapton.Select(props[0], props[1], props[2])
}

const span = (...props: any[]) => {
return new Clapton.Span(...props)
}

const textarea = (...props: any[]) => {
return new Clapton.TextArea(props[0], props[1], props[2])
}

const input = (...props: any[]) => {
return new Clapton.TextField(props[0], props[1], props[2])
}

const text = (...props: any[]) => {
return new Clapton.Text(props[0])
}

const c = (name: string, ...props: any[]) => {
switch (name) {
case "bq":
return bq(...props)
case "box":
return box(...props)
case "b":
return b(...props)
case "button":
return button(...props)
case "check":
return check(...props)
case "code":
return code(...props)
case "datetime":
return datetime(...props)
case "el":
return el(...props)
case "embed":
return embed(...props)
case "em":
return em(...props)
case "form":
return form(...props)
case "h":
return h(...props)
case "img":
return img(...props)
case "a":
return a(...props)
case "li":
return li(...props)
case "ul":
return ul(...props)
case "ol":
return ol(...props)
case "p":
return p(...props)
case "q":
return q(...props)
case "radio":
return radio(...props)
case "select":
return select(...props)
case "span":
return span(...props)
case "textarea":
return textarea(...props)
case "input":
return input(...props)
case "text":
return text(...props)
default:
return new Clapton.Component(...props)
}
}
import { c } from "./c-base"

export default c
Loading

0 comments on commit ea35388

Please sign in to comment.