Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/docs/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@

<div class="mt-2">
<router-outlet />
<flowbite-scroll-top />
</div>

<ng-template #footerContent>
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'flowbite-angular/navbar';
import { FlowbiteRouterLinkDirective } from 'flowbite-angular/router-link';
import { FlowbiteRouterLinkActiveDirective } from 'flowbite-angular/router-link-active';
import { ScrollTopComponent } from 'flowbite-angular/scroll-top';

import { Location } from '@angular/common';
import { Component, computed, inject } from '@angular/core';
Expand Down Expand Up @@ -44,6 +45,7 @@ import {
FlowbiteRouterLinkDirective,
FlowbiteRouterLinkActiveDirective,
BadgeComponent,
ScrollTopComponent,
],
selector: 'flowbite-root',
templateUrl: './app.component.html',
Expand Down
33 changes: 28 additions & 5 deletions libs/flowbite-angular/scroll-top/scroll-top.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { BaseComponent } from 'flowbite-angular';
import { IconComponent, IconRegistry } from 'flowbite-angular/icon';
import { CHEVRON_UP_SVG_ICON } from 'flowbite-angular/utils';

import type { OnInit } from '@angular/core';
import { NgTemplateOutlet } from '@angular/common';
import type { OnInit, TemplateRef } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -31,6 +32,10 @@ export const FLOWBITE_SCROLL_TOP_POSITION_DEFAULT_VALUE = new InjectionToken<
keyof ScrollTopPositions
>('FLOWBITE_SCROLL_TOP_POSITION_DEFAULT_VALUE');

export const FLOWBITE_SCROLL_TOP_ICON_DEFAULT_VALUE = new InjectionToken<
TemplateRef<unknown> | undefined
>('FLOWBITE_SCROLL_TOP_ICON_DEFAULT_VALUE');

export const FLOWBITE_SCROLL_TOP_CUSTOM_STYLE_DEFAULT_VALUE = new InjectionToken<
DeepPartial<ScrollTopTheme>
>('FLOWBITE_SCROLL_TOP_CUSTOM_STYLE_DEFAULT_VALUE');
Expand All @@ -44,6 +49,10 @@ export const scrollTopDefaultValueProvider = makeEnvironmentProviders([
provide: FLOWBITE_SCROLL_TOP_POSITION_DEFAULT_VALUE,
useValue: 'bottom-right',
},
{
provide: FLOWBITE_SCROLL_TOP_ICON_DEFAULT_VALUE,
useValue: undefined,
},
{
provide: FLOWBITE_SCROLL_TOP_CUSTOM_STYLE_DEFAULT_VALUE,
useValue: {},
Expand All @@ -56,10 +65,16 @@ export const scrollTopDefaultValueProvider = makeEnvironmentProviders([
@Component({
selector: 'flowbite-scroll-top',
standalone: true,
imports: [IconComponent],
template: `<flowbite-icon
svgIcon="flowbite-angular:chevron-up"
class="w-5 h-5" />`,
imports: [IconComponent, NgTemplateOutlet],
template: `
@if (icon()) {
<ng-container [ngTemplateOutlet]="icon()!" />
} @else {
<flowbite-icon
svgIcon="flowbite-angular:chevron-up"
class="w-5 h-5" />
}
`,
host: {
'(click)': 'onClick()',
},
Expand Down Expand Up @@ -93,8 +108,16 @@ export class ScrollTopComponent extends BaseComponent<ScrollTopClass> implements
* @default bottom-right
*/
public position = model(inject(FLOWBITE_SCROLL_TOP_POSITION_DEFAULT_VALUE));
/**
* Set the scroll top icon
*
* @default undefined
*/
public icon = model(inject(FLOWBITE_SCROLL_TOP_ICON_DEFAULT_VALUE));
/**
* Set the custom style for this scroll top
*
* @default {}
*/
public customStyle = model(inject(FLOWBITE_SCROLL_TOP_CUSTOM_STYLE_DEFAULT_VALUE));
//#endregion
Expand Down
Loading