-
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.
Merge pull request #31 from kacper-cyra/ui-18/add_portrait_component
add portrait component
- Loading branch information
Showing
7 changed files
with
65 additions
and
3 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,13 @@ | ||
## Conventions | ||
|
||
For file structure reference this [repo](https://github.com/wiledal/vanilla-bean). | ||
|
||
Branches are named after category, task number and with meaningful description. E.g.'ui-18/add_portrait_component'. | ||
|
||
## Warnings | ||
|
||
Parcel in v2 has a [bug](https://github.com/parcel-bundler/parcel/issues/5965) witch it's cache and will not update changes on website without manual page refresh. | ||
|
||
## Useful resources | ||
|
||
- [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements), |
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export const App = ({ options }) => {}; | ||
export const App = ({ options: { rootNodeId } }) => { | ||
const rootNode = document.getElementById(rootNodeId); | ||
}; |
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,30 @@ | ||
import * as classes from './style.module.scss'; | ||
|
||
export const PORTRAIT_COMPONENT_NAME = 'portrait-component'; | ||
|
||
class Portrait extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this._contents = new DocumentFragment(); | ||
|
||
this.imageContainer = Portrait.imageContainerBuilder(); | ||
|
||
this._contents.appendChild(this.imageContainer); | ||
} | ||
|
||
connectedCallback() { | ||
this.imageContainer.style.backgroundImage = `url(${this.getAttribute( | ||
'data-image-url', | ||
)})`; | ||
this.appendChild(this._contents); | ||
} | ||
|
||
static imageContainerBuilder() { | ||
const imageContainer = document.createElement('div'); | ||
imageContainer.className = classes.imageContainer; | ||
|
||
return imageContainer; | ||
} | ||
} | ||
|
||
customElements.define(PORTRAIT_COMPONENT_NAME, Portrait); |
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,11 @@ | ||
@use '../../themes/theme.scss' as *; | ||
|
||
.portrait { | ||
display: flex; | ||
flex: 1; | ||
box-shadow: $red-box-shadow; | ||
border-radius: $border-radius; | ||
min-height: 100px; | ||
background-size: cover; | ||
background-position: center; | ||
} |
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
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,3 @@ | ||
$red-box-shadow: 4px 4px 40px 0px #ff0000e5, 0px 4px 4px 0px #00000040; | ||
|
||
$border-radius: 16px; |