forked from b00tc4mp/isdi-bootcamp-202409
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
/* | ||
class Button(text, type) { | ||
Compo.call(this, document.createElement('button')) | ||
this.container.innerText = text | ||
this.container.type = type | ||
} | ||
Button.prototype = Object.create(Compo.prototype) | ||
Button.prototype.constructor = Button */ | ||
|
||
class Button extends Compo { | ||
constructor (text, type){ | ||
super(document.createElement('button')) | ||
|
||
this.container.innerText = text | ||
this.container.type = type | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Constructs Compo instances | ||
* | ||
* @param {HTMLElement} container The DOM container of the Compo instance | ||
*/ | ||
/* function Compo(container) { | ||
this.children = [] | ||
this.container = container | ||
this.parent = null | ||
} | ||
Compo.prototype.add = function (child) { | ||
this.children.push(child) | ||
child.parent = this | ||
this.container.appendChild(child.container) | ||
} | ||
Compo.prototype.removeSelf = function () { | ||
var index = this.parent.children.findIndex(function (child) { | ||
return child === this | ||
}.bind(this)) | ||
if (index > -1) | ||
this.parent.children.splice(index, 1) | ||
this.container.remove() | ||
} | ||
Compo.prototype.addBehavior= function (type, callback) { | ||
this.container.addEventListener(type, callback) | ||
} | ||
*/ | ||
|
||
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.pΓ rent.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) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
|
||
/**Constructs Form instances */ | ||
class Form extends Compo{ | ||
constructor() { | ||
super(document.createElement('form')) | ||
} | ||
|
||
reset() { | ||
this.container.reset() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Constructs Heading instances | ||
*/ | ||
/* function Heading(text, level) { | ||
Compo.call(this, document.createElement('h' + level)) | ||
this.container.innerText = text | ||
} | ||
Heading.extends(Compo) */ | ||
|
||
class Heading extends Compo { | ||
constructor(text, level) { | ||
super(document.createElement(`h${level}`)) | ||
|
||
this.container.innerText = text | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* function Image(address) { | ||
Compo.call(this, document.createElement('img')) | ||
this.container.src = address | ||
this.container.style.width = '100%' | ||
} | ||
Image.extends(Compo) */ | ||
|
||
class Image extends Compo{ | ||
constructor(address) { | ||
super(document.createElement('img')) | ||
|
||
this.container.src = address | ||
this.container.style.width = '100%' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Constructs Input Instances | ||
*/ | ||
/* function Input(type, id) { | ||
Compo.call(this, document.createElement('input')) | ||
this.container.style.width = '100%' | ||
this.container.style.boxSizing = 'border-box' | ||
this.container.type = type | ||
this.container.id = id | ||
} | ||
Input.extends(Compo) | ||
Input.prototype.getValue = function () { | ||
return this.container.value | ||
} | ||
Input.prototype.setValue = function (value) { | ||
this.container.value = value | ||
} | ||
Input.prototype.getType = function () { | ||
return this.container.type | ||
} | ||
Input.prototype.setType = function (type) { | ||
this.container.type = type | ||
} */ | ||
|
||
class Input extends Compo { | ||
constructor(type, id) { | ||
super(document.createElement('input')) | ||
|
||
this.container.type = type | ||
this.container.id = id | ||
} | ||
|
||
getValue() { | ||
return this.container.value | ||
} | ||
|
||
setValue(value) { | ||
this.container.value = value | ||
} | ||
|
||
getType() { | ||
return this.container.type | ||
} | ||
setType(type) { | ||
this.container.type = type | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Constructs Label instances | ||
* | ||
* @param {string} text The text of the label | ||
* @param {string} id The id of the input to relate with | ||
*/ | ||
/* function Label(text, id) { | ||
Compo.call(this, document.createElement('label')) | ||
this.container.innerText = text | ||
this.container.htmlFor = id | ||
} | ||
Label.extends(Compo) */ | ||
|
||
class Label extends Compo { | ||
constructor (text, id){ | ||
super(document.createElement('label')) | ||
|
||
this.container.innerText = text | ||
this.container.htmlFor = id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Constructs Link instances | ||
* | ||
* @param {string} text The text of the link | ||
*/ | ||
/* function Link(text) { | ||
Compo.call(this, document.createElement('a')) | ||
this.container.innerText = text | ||
this.container.href = '' | ||
} | ||
Link.extends(Compo) */ | ||
|
||
class Link extends Compo { | ||
constructor(text) { | ||
super(document.createElement('a')) | ||
|
||
this.container.innerText = text | ||
this.container.href = '' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ListItem extends Compo { | ||
constructor() { | ||
super(document.createElement('li')) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* function Paragraph(text) { | ||
Compo.call(this, document.createElement('p')) | ||
this.container.innerText = text | ||
} | ||
Paragraph.extends(Compo) | ||
Paragraph.prototype.setText = function (text) { | ||
thbis.container.innerText = text | ||
} | ||
Paragraph.prototype.getText = function() { | ||
return this.container.innerText | ||
} */ | ||
|
||
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 | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* function PasswordInput(id) { | ||
Compo.call(this, document.createElement('div')) | ||
this.container.style.display = 'flex' | ||
var input = new Input('password', id) | ||
input.container.style.paddingRight = '18px' | ||
this.add(input) | ||
var span = new Span('π') | ||
this.add(span) | ||
span.addBehavior('click', function() { | ||
if (span.getText() === 'π') { | ||
input.setType('text') | ||
span.setText('π³') | ||
} else { | ||
input.setType('password') | ||
span.setText('π') | ||
} | ||
}) | ||
} | ||
PasswordInput.extends(Compo) | ||
PasswordInput.prototype.getValue = function () { | ||
return this.children[0].container.value | ||
} | ||
PasswordInput.prototype.setValue = function (value) { | ||
this.container.value = value | ||
} */ | ||
|
||
class PasswordInput extends Compo { | ||
constructor(id) { | ||
super(document.createElement('div')) | ||
|
||
const input = new Input('password', id) | ||
this.add(input) | ||
|
||
const span = new Span('π') | ||
this.container.style.cursor = 'pointer' | ||
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 | ||
} | ||
} |
Oops, something went wrong.