Skip to content

Commit

Permalink
estructure unsocial with app and api folders b00tc4mp#168
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Romera Claros authored and Javier Romera Claros committed Oct 28, 2024
1 parent e170da4 commit 91f6c91
Show file tree
Hide file tree
Showing 120 changed files with 1,369 additions and 3 deletions.
Binary file added staff/javier-romera/unsocial/.DS_Store
Binary file not shown.
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions staff/javier-romera/unsocial/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "api",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "unsocial",
"name": "app",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
13 changes: 13 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Constructs Button instances
*
* @param {string} text The text of the button
* @param {string} type The button type
*/
class Button extends Compo {
constructor(type, text) {
super(document.createElement('button'))
this.container.innerText = text
this.container.type = type
}
}
19 changes: 19 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
*
* @param {*} text
*/
class Code extends Compo {
constructor(text) {
super(document.createElement('code'))

this.container.innerText = text
}

setText(text) {
this.container.innerText = text
}

getText() {
return this.container.innerText
}
}
32 changes: 32 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Compo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Constructs Compo instances
*
* @param {HTMLElement} container The DOM container of the Compo instance
*/
class Compo {
constructor(container) {
this.children = []
this.container = container
this.parent = null
}

add(child) {
this.children.push(child)
child.parent = this

this.container.appendChild(child.container)
}

removeSelf() {
const index = this.parent.children.findIndex(child => child === this)

if (index > -1)
this.parent.children.splice(index, 1)

this.container.remove()
}

addBehavior(type, callback) {
this.container.addEventListener(type, callback)
}
}
12 changes: 12 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Constructs Form instances
*/
class Form extends Compo {
constructor() {
super(document.createElement('form'))
}

reset() {
this.container.reset()
}
}
12 changes: 12 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Heading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Constructs Heading instances
*
* @param {string} text The text of the heading
* @param {number} level The heading level
*/
class Heading extends Compo {
constructor(text, level) {
super(document.createElement('h' + level))
this.container.innerText = text
}
}
11 changes: 11 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
*
*/
class Image extends Compo {
constructor(address) {
super(document.createElement('img'))

this.container.src = address
this.container.style.width = '100%'
}
}
32 changes: 32 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Constructs Input instances
*
* @param {string} type The input type
* @param {string} id The input id
*/
class Input extends Compo {
constructor(id, type) {
super(document.createElement('input'))
// this.container.style.width = '100%'
// this.container.style.boxSizing = 'border-box'

this.container.id = id
this.container.type = type
}

getValue() {
return this.container.value
}

setValue(value) {
this.container.value = value
}

getType() {
return this.container.type
}

setType(type) {
this.container.type = type
}
}
13 changes: 13 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Label.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Constructs Label instances
*
* @param {string} text The text of the label
* @param {string} id The id of the input to relate with
*/
class Label extends Compo {
constructor(text, id) {
super(document.createElement('label'))
this.container.innerText = text
this.container.htmlFor = id
}
}
12 changes: 12 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Constructs Link instances
*
* @param {string} text The text of the link
*/
class Link extends Compo {
constructor(text) {
super(document.createElement('a'))
this.container.href = ''
this.container.innerText = text
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
*
*/
class ListItem extends Compo {
constructor() {
super(document.createElement('li'))
}
}
19 changes: 19 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Paragraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
*
* @param {*} text
*/
class Paragraph extends Compo {
constructor(text) {
super(document.createElement('p'))

this.container.innerText = text
}

setText(text) {
this.container.innerText = text
}

getText() {
return this.container.innerText
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Constructs PasswordInput instances
*
* @param {string} id The input id
*/
class PasswordInput extends Compo {
constructor(id) {
super(document.createElement('div'))
this.container.style.display = 'flex'

const input = new Input('password', id)
input.container.style.paddingRight = '18px'
this.add(input)

const span = new Span('😌')
span.container.style.cursor = 'pointer'
span.container.style.position = 'absolute'
span.container.style.right = '10px'
this.add(span)

span.addBehavior('click', () => {
if (span.getText() === '😌') {
input.setType('text')
span.setText('😳')
} else {
input.setType('password')
span.setText('😌')
}
})
}

getValue() {
return this.children[0].container.value
}

setValue(value) {
this.container.value = value
}
}
19 changes: 19 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Preformatted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
*
* @param {*} text
*/
class Preformatted extends Compo {
constructor(text) {
super(document.createElement('pre'))

this.container.innerText = text
}

setText(text) {
this.container.innerText = text
}

getText() {
return this.container.innerText
}
}
18 changes: 18 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Snippet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
*
* @param {*} text
*/
class Snippet extends Compo {
constructor(title, text) {
super(document.createElement('div'))

const heading = new Heading(title, 4)
this.add(heading)

const pre = new Preformatted('')
const code = new Code(text)
pre.add(code)

this.add(pre)
}
}
20 changes: 20 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Span.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Constructs Span instances
*
* @param {string} text The text inside span
*/
class Span extends Compo {
constructor(text) {
super(document.createElement('span'))

this.container.innerText = text
}

setText(text) {
this.container.innerText = text
}

getText() {
return this.container.innerText
}
}
19 changes: 19 additions & 0 deletions staff/javier-romera/unsocial/zzz/unsocial.01/compo/Time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
*
* @param {*} text
*/
class Time extends Compo {
constructor(text) {
super(document.createElement('time'))

this.container.innerText = text
}

setText(text) {
this.container.innerText = text
}

getText() {
return this.container.innerText
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
*
*/
class UnorderedList extends Compo {
constructor() {
super(document.createElement('ul'))
}
}
Loading

0 comments on commit 91f6c91

Please sign in to comment.