-
Notifications
You must be signed in to change notification settings - Fork 1
feat: static css styling inserted #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
frankpizzella-topsort
wants to merge
8
commits into
main
Choose a base branch
from
feat/frank/css-styling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abb03df
feat: static css styling inserted
frankpizzella-topsort 4b1a177
feat: fixed biome errors
frankpizzella-topsort c551226
feat: ensured width and height attributes are unchanged
frankpizzella-topsort 8d56ad0
feat: fixed documentation
frankpizzella-topsort c738037
custom class
anonvt 15d8c2f
reolved name clash
anonvt 715a14b
lint
anonvt 3baa6ff
lint
anonvt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -73,9 +73,10 @@ function getNoWinnersElement(): TemplateResult { | |
|
|
||
| function getBannerElement( | ||
| banner: Banner, | ||
| width: number, | ||
| height: number, | ||
| newTab: boolean, | ||
| width?: number, | ||
| height?: number, | ||
| bannerClass?: string, | ||
| ): TemplateResult { | ||
| if (window.TS_BANNERS.getBannerElement) { | ||
| const element = window.TS_BANNERS.getBannerElement(banner); | ||
|
|
@@ -102,19 +103,39 @@ function getBannerElement( | |
| return false; | ||
| } | ||
| })(); | ||
|
|
||
| const containerClass = bannerClass ? `ts-banner ${bannerClass}` : "ts-banner"; | ||
|
|
||
| const containerStyle = [ | ||
| "display: block", | ||
| width ? `--ts-banner-width: ${width}px` : "", | ||
| height ? `--ts-banner-height: ${height}px` : "", | ||
| ] | ||
| .filter(Boolean) | ||
| .join("; "); | ||
|
|
||
| // let CSS cascade | ||
| const mediaStyle = | ||
| width && height | ||
| ? `width: ${width}px; height: ${height}px; object-fit: cover;` | ||
| : width | ||
| ? `width: ${width}px; height: auto; object-fit: cover;` | ||
| : height | ||
| ? `width: 100%; height: ${height}px; object-fit: cover;` | ||
| : "width: 100%; height: auto; object-fit: cover;"; | ||
|
|
||
| const media = isVideo | ||
| ? html` | ||
| <hls-video | ||
| src="${src}" | ||
| width="${width}px" | ||
| height="${height}px" | ||
| styles=${mediaStyle} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im generally ok with this if there are no users of banners.js using video; it is the right move. the otehr option is to do a major bump due to your previous change |
||
| ></hls-video> | ||
| ` | ||
| : html` | ||
| <img | ||
| src="${src}" | ||
| alt="Topsort banner" | ||
| style="width:${width}px; height:${height}px; object-fit:cover;" | ||
| style=${mediaStyle} | ||
| /> | ||
| `; | ||
|
|
||
|
|
@@ -124,9 +145,12 @@ function getBannerElement( | |
| : html`<a href="${href}">${media}</a>`; | ||
| return html` | ||
| <div | ||
| class=${containerClass} | ||
| data-ts-clickable | ||
| data-ts-resolved-bid=${banner.resolvedBidId} | ||
| class="ts-banner" | ||
anonvt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| data-ts-width=${width ?? ""} | ||
| data-ts-height=${height ?? ""} | ||
| style=${containerStyle} | ||
| > | ||
| ${wrappedMedia} | ||
| </div> | ||
|
|
@@ -145,6 +169,7 @@ const bannerContextHasChanged = (newVal: BannerContext, oldVal?: BannerContext) | |
| newVal.width !== oldVal.width || | ||
| newVal.height !== oldVal.height || | ||
| newVal.newTab !== oldVal.newTab || | ||
| newVal.bannerClass !== oldVal.bannerClass || | ||
| !!newVal.error !== !!oldVal.error || | ||
| newVal.banners?.length !== oldVal.banners?.length | ||
| ); | ||
|
|
@@ -181,6 +206,7 @@ export class TopsortBanner extends BannerComponent(LitElement) { | |
| width: this.width, | ||
| height: this.height, | ||
| newTab: this.newTab, | ||
| bannerClass: this.bannerClass, | ||
| }; | ||
|
|
||
| @property({ type: Boolean, attribute: "context" }) | ||
|
|
@@ -203,7 +229,7 @@ export class TopsortBanner extends BannerComponent(LitElement) { | |
| if (!banners.length) { | ||
| return getNoWinnersElement(); | ||
| } | ||
| return getBannerElement(banners[0], this.width, this.height, this.newTab); | ||
| return getBannerElement(banners[0], this.newTab, this.width, this.height, this.bannerClass); | ||
| }, | ||
| error: (error) => getErrorElement(error), | ||
| }); | ||
|
|
@@ -221,13 +247,15 @@ export class TopsortBanner extends BannerComponent(LitElement) { | |
| if ( | ||
| changedProperties.has("width") || | ||
| changedProperties.has("height") || | ||
| changedProperties.has("newTab") | ||
| changedProperties.has("newTab") || | ||
| changedProperties.has("bannerClass") | ||
| ) { | ||
| Promise.resolve().then(() => { | ||
| this.context = { | ||
| width: this.width, | ||
| height: this.height, | ||
| newTab: this.newTab, | ||
| bannerClass: this.bannerClass, | ||
| }; | ||
| }); | ||
| } | ||
|
|
@@ -263,9 +291,10 @@ export class TopsortBannerSlot extends LitElement { | |
| } | ||
| return getBannerElement( | ||
| this.context.banners[this.rank - 1], | ||
| this.context.newTab, | ||
| this.context.width, | ||
| this.context.height, | ||
| this.context.newTab, | ||
| this.context.bannerClass, | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -278,8 +307,7 @@ export class TopsortBannerSlot extends LitElement { | |
| @customElement("hls-video") | ||
| export class HlsVideo extends LitElement { | ||
| @property({ type: String }) src = ""; // HLS manifest URL | ||
| @property({ type: String }) width = "800px"; | ||
| @property({ type: String }) height = "400px"; | ||
| @property({ type: String }) styles = ""; | ||
|
|
||
| private get videoId() { | ||
| try { | ||
|
|
@@ -297,6 +325,7 @@ export class HlsVideo extends LitElement { | |
| autoplay | ||
| loop | ||
| playsinline | ||
| style=${this.styles} | ||
| ></video> | ||
| `; | ||
| } | ||
|
|
@@ -305,10 +334,6 @@ export class HlsVideo extends LitElement { | |
| const video = this.shadowRoot?.getElementById(this.videoId) as HTMLVideoElement; | ||
| if (!video) return; | ||
|
|
||
| video.style.width = this.width; | ||
| video.style.height = this.height; | ||
| video.style.objectFit = "cover"; | ||
|
|
||
| let Hls: HlsConstructor; | ||
| try { | ||
| Hls = await hlsDependency.load(); | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't change the order of variables, thats a breaking change