Skip to content

Commit

Permalink
Modernize the project by adding native Typescript types. Making a class
Browse files Browse the repository at this point in the history
TopBar that can be imported as an ESM project. And added container
option because I saw in an open issue.

Also moved the tooling for minimizing to Rollup which allow minification
with terser but aslo Typescript transpilation and differen export module
formats
  • Loading branch information
andresgutgon committed Nov 1, 2024
1 parent 74b4d71 commit 56c5502
Show file tree
Hide file tree
Showing 10 changed files with 1,246 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ lib-cov
pids
logs
results

dist
npm-debug.log
node_modules
node_modules
58 changes: 37 additions & 21 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
export interface BarColors {
[key: string]: string
type TopBarOptions = {
container?: HTMLElement;
autoRun?: boolean;
barThickness?: number;
barColors?: Record<string, string>;
shadowBlur?: number;
showShadow?: boolean;
shadowColor?: string;
className?: string;
};
declare class Topbar {
private container;
private canvas;
private progressTimerId;
private autoRun;
private showing;
private currentProgress;
private barThickness;
private barColors;
private shadowBlur;
private shadowColor;
private className;
private fadeTimerId;
private delayTimerId;
constructor({ container, autoRun, barThickness, barColors, shadowBlur, shadowColor, className, }?: Partial<TopBarOptions>);
show(delay?: number): void;
hide(): void;
progress(to?: number | string): number;
private hideLoop;
private loopShow;
private createCanvas;
private repaint;
}
declare function config(options: Partial<TopBarOptions>): Topbar;
declare function show(delay?: number): void;
declare function hide(): void;
declare function progress(to?: number | string): number;

export interface TopbarConfigOptions {
autoRun?: boolean
barThickness?: number
barColors?: BarColors
shadowBlur?: number
shadowColor?: string
className?: string
}

export interface Topbar {
config: (options: TopbarConfigOptions) => void
show: (delay?: number) => void
progress: (to?: number | string) => number
hide: () => void
}

declare const topbar: Topbar

export default topbar
export { type TopBarOptions, Topbar, config, hide, progress, show };
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
$('#btnStartAdvanced').click(function() {
resetToDefaults()
topbar.config({
autoRun : false,
autoRun : false,
barThickness : 5,
barColors : {
'0' : 'rgba(26, 188, 156, .7)',
Expand All @@ -77,13 +77,13 @@
})
topbar.show();
(function step() {
setTimeout(function() {
setTimeout(function() {
if (topbar.progress('+.01') < 1) step()
}, 16)
})()
})
$('#btnStopAdvanced').click(function() {
topbar.hide()
topbar.hide()
})
})
</script>
Expand Down Expand Up @@ -166,7 +166,7 @@ <h4>Advanced</h4>
<pre class="prettyprint">
$('#btnStartAdvanced').click(function() {
topbar.config({
autoRun : false,
autoRun : false,
barThickness : 5,
barColors : {
'0' : 'rgba(26, 188, 156, .7)',
Expand All @@ -179,7 +179,7 @@ <h4>Advanced</h4>
})
topbar.show();
(function step() {
setTimeout(function() {
setTimeout(function() {
if (topbar.progress('+.01') &lt; 1) step()
}, 16)
})()
Expand Down
Loading

0 comments on commit 56c5502

Please sign in to comment.