gd-bs 6.1.5 → 6.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.html CHANGED
@@ -15,6 +15,7 @@
15
15
  <h1>Library</h1>
16
16
  <form>
17
17
  <div id="dev"></div>
18
+ <div id="icon-link"></div>
18
19
  <div id="alert"></div>
19
20
  <div id="btn-loading"></div>
20
21
  <div id="spinner"></div>
@@ -86,6 +87,12 @@
86
87
  });
87
88
 
88
89
  // Components
90
+ GD.Components.IconLink({
91
+ el: document.getElementById("icon-link"),
92
+ content: "Icon Link",
93
+ iconType: GD.Icons(GD.IconTypes.Badge3d),
94
+ type: GD.Components.IconLinkTypes.AfterText
95
+ })
89
96
  GD.Components.ListBox({
90
97
  el: document.getElementById("listbox"),
91
98
  label: "List Box Example:",
@@ -1020,7 +1027,7 @@
1020
1027
  type: 2,
1021
1028
  options: {
1022
1029
  autoClose: false,
1023
- backdrop: false
1030
+ backdrop: true
1024
1031
  }
1025
1032
  });
1026
1033
 
@@ -1124,8 +1131,8 @@
1124
1131
  });
1125
1132
  window["myNavTabs"] = GD.Components.Nav({
1126
1133
  el: document.querySelector("#navTabs"),
1127
- fadeTabs: true,
1128
- isTabs: true,
1134
+ //fadeTabs: true,
1135
+ isUnderline: true,
1129
1136
  items: [{
1130
1137
  title: "NavTab 1",
1131
1138
  tabContent: "This is the content for tab 1.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.1.5",
3
+ "version": "6.1.6",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -0,0 +1,71 @@
1
+ import { IIconLink, IIconLinkProps } from "./types";
2
+ import { Base } from "../base";
3
+ import { appendContent } from "../common";
4
+ import { HTML } from "./templates";
5
+
6
+ /**
7
+ * Icon Link Types
8
+ */
9
+ export enum IconLinkTypes {
10
+ AfterText = 1,
11
+ BeforeText = 2
12
+ }
13
+ /**
14
+ * Icon Link
15
+ * @property props - The list box properties.
16
+ */
17
+ class _IconLink extends Base<IIconLinkProps> implements IIconLink {
18
+ private _elIcon: HTMLOrSVGElement = null;
19
+
20
+ // Constructor
21
+ constructor(props: IIconLinkProps, template: string = HTML) {
22
+ super(template, props);
23
+
24
+ // Configure the list box
25
+ this.configure();
26
+
27
+ // Configure the events
28
+ this.configureEvents();
29
+
30
+ // Configure the parent
31
+ this.configureParent();
32
+ }
33
+
34
+ // Configures the list box
35
+ private configure() {
36
+ // Render the content
37
+ appendContent(this.el, this.props.content);
38
+
39
+ // Set the icon if it exists
40
+ if (this.props.iconType) {
41
+ if (typeof (this.props.iconType) === "function") {
42
+ // Set the icon
43
+ this._elIcon = this.props.iconType(this.props.iconSize, this.props.iconSize, this.props.iconClassName);
44
+ }
45
+ // Else, it's an element
46
+ else if (typeof (this.props.iconType === "object")) {
47
+ // Set the icon
48
+ this._elIcon = this.props.iconType;
49
+ } else { return; }
50
+
51
+ // See if we are rendering the content first
52
+ if (this.props.type == IconLinkTypes.AfterText) {
53
+ // Append the icon
54
+ this.el.appendChild(this._elIcon);
55
+ } else {
56
+ // Prepend the icon
57
+ this.el.prepend(this._elIcon);
58
+ }
59
+ }
60
+ }
61
+
62
+ // Configures the events
63
+ private configureEvents() {
64
+ }
65
+
66
+ /**
67
+ * Public Interface
68
+ */
69
+
70
+ }
71
+ export const IconLink = (props: IIconLinkProps, template?: string): IIconLink => { return new _IconLink(props, template); }
@@ -0,0 +1,2 @@
1
+ // Form
2
+ export const HTML = `<a class="icon-link" href="#"></a>`.trim();
@@ -0,0 +1,68 @@
1
+ /**
2
+ * <div id="demo"></div>
3
+ * <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gd-sprest-bs/5.0.3/gd-sprest-bs.min.js"></script>
4
+ * <script type="text/javascript">
5
+ * // Wait for the window to be loaded
6
+ * window.addEventListener("load", function() {
7
+ * // Create the icon link
8
+ * $REST.Components.IconLink({
9
+ * el: document.querySelector("#demo"),
10
+ * content: "Icon Link",
11
+ * type: $REST.Components.IconLinkTypes.BeforeIcon,
12
+ * icon: $REST.Icons($REST.IconTypes.Badge3d)
13
+ * });
14
+ * });
15
+ * </script>
16
+ */
17
+
18
+ /**
19
+ * Icon Link
20
+ *
21
+ * ```ts
22
+ * import { Components } from "gd-sprest-bs";
23
+ * import { Badge3d } from "gd-sprest-bs/build/icons/svgs/badge3d";
24
+ *
25
+ * // Create the icon link
26
+ * let el = document.querySelector("#icon-link");
27
+ * Components.IconLink({
28
+ * el: el,
29
+ * content: "Icon Link",
30
+ * iconType: Badge3d,
31
+ * type: Components.IconLinkTypes.AfterIcon,
32
+ * });
33
+ * ```
34
+ */
35
+ export const IconLink: (props: IIconLinkProps, template?: string) => IIconLink;
36
+
37
+ /**
38
+ * Icon Link Types
39
+ */
40
+ export const IconLinkTypes: IIconLinkTypes;
41
+
42
+ import { IBase, IBaseProps } from "../types";
43
+
44
+ /**
45
+ * Icon Link
46
+ */
47
+ export interface IIconLink extends IBase<IIconLinkProps> { }
48
+
49
+ /**
50
+ * Icon Link Properties
51
+ */
52
+ export interface IIconLinkProps<T = Element> extends IBaseProps<IIconLink> {
53
+ content?: string | T;
54
+ data?: any;
55
+ href?: string;
56
+ iconClassName?: string;
57
+ iconSize?: number;
58
+ iconType?: Function;
59
+ type?: number;
60
+ }
61
+
62
+ /**
63
+ * Icon Link Types
64
+ */
65
+ export type IIconLinkTypes = {
66
+ AfterText: number;
67
+ BeforeText: number;
68
+ }
@@ -11,6 +11,7 @@ export * from "./checkboxGroup";
11
11
  export * from "./collapse";
12
12
  export * from "./dropdown";
13
13
  export * from "./form";
14
+ export * from "./iconLink";
14
15
  export * from "./inputGroup";
15
16
  export * from "./jumbotron";
16
17
  export * from "./listBox";
@@ -27,13 +27,14 @@ class _Nav extends Base<INavProps> implements INav {
27
27
  // Configure the card group
28
28
  private configure(itemTemplate: string) {
29
29
  // Update the navigation
30
- let nav = this.el.querySelector(".nav");
30
+ let nav = this.el.classList.contains("nav") ? this.el : this.el.querySelector(".nav");
31
31
  if (nav) {
32
32
  this.props.id ? nav.id = this.props.id : null;
33
33
  this.props.enableFill ? this.el.classList.add("nav-fill") : null;
34
34
  this.props.isJustified ? this.el.classList.add("nav-justified") : null;
35
35
  this.props.isPills ? this.el.classList.add("nav-pills") : null;
36
36
  this.props.isTabs ? this.el.classList.add("nav-tabs") : null;
37
+ this.props.isUnderline ? this.el.classList.add("nav-underline") : null;
37
38
  this.props.isVertical ? this.el.classList.add("flex-column") : null;
38
39
  }
39
40
 
@@ -48,11 +49,11 @@ class _Nav extends Base<INavProps> implements INav {
48
49
  }
49
50
 
50
51
  // Configures the tab link event
51
- private configureTabEvents(tab: NavLink) {
52
+ private configureLinkEvents(link: NavLink) {
52
53
  // Add a click event
53
- tab.el.addEventListener("click", () => {
54
+ link.el.addEventListener("click", () => {
54
55
  let prevTab: INavLink = null;
55
- let newTab: INavLink = tab;
56
+ let newTab: INavLink = link;
56
57
 
57
58
  // Parse the links
58
59
  for (let i = 0; i < this._links.length; i++) {
@@ -69,7 +70,7 @@ class _Nav extends Base<INavProps> implements INav {
69
70
  }
70
71
 
71
72
  // Toggle the link
72
- tab.toggle(this.props.fadeTabs);
73
+ link.toggle(this.props.fadeTabs);
73
74
 
74
75
  // Call the click event
75
76
  this.props.onClick ? this.props.onClick(newTab, prevTab) : null;
@@ -82,7 +83,7 @@ class _Nav extends Base<INavProps> implements INav {
82
83
  this._links = [];
83
84
 
84
85
  // Get the nav and tab elements
85
- let nav = this.el.querySelector(".nav") || this.el;
86
+ let nav = this.el.classList.contains("nav") ? this.el : this.el.querySelector(".nav");
86
87
  if (nav) {
87
88
  let tabs = this.el.querySelector(".tab-content");
88
89
 
@@ -94,11 +95,11 @@ class _Nav extends Base<INavProps> implements INav {
94
95
  nav.appendChild(link.el);
95
96
  this._links.push(link);
96
97
 
98
+ // Configure the link event
99
+ this.configureLinkEvents(link);
100
+
97
101
  // See if we are rendering tabs
98
102
  if (tabs) {
99
- // Configure the events
100
- this.configureTabEvents(link);
101
-
102
103
  // Add the tab content
103
104
  tabs.appendChild(link.elTabContent);
104
105
 
@@ -112,13 +112,13 @@ export class NavLink extends Base<INavLinkProps> implements INavLink {
112
112
  if (this.isActive) {
113
113
  // Hide this link and tab
114
114
  this._elLink.classList.remove("active");
115
- this._elTab.classList.remove("active");
116
- this._elTab.classList.remove("show");
115
+ this._elTab ? this._elTab.classList.remove("active") : null;
116
+ this._elTab ? this._elTab.classList.remove("show") : null;
117
117
  } else {
118
118
  // Show this link and tab
119
119
  this._elLink.classList.add("active");
120
- this._elTab.classList.add("active");
121
- fadeTabs ? this._elTab.classList.add("show") : null;
120
+ this._elTab ? this._elTab.classList.add("active") : null;
121
+ this._elTab && fadeTabs ? this._elTab.classList.add("show") : null;
122
122
  }
123
123
  }
124
124
  }
@@ -90,6 +90,7 @@ export interface INavProps<T = Element> extends IBaseProps<INav> {
90
90
  isJustified?: boolean;
91
91
  isPills?: boolean;
92
92
  isTabs?: boolean;
93
+ isUnderline?: boolean;
93
94
  isVertical?: boolean;
94
95
  onClick?: (newTab?: INavLink, prevTab?: INavLink) => void;
95
96
  onLinkRendered?: (el?: HTMLElement, item?: INavLinkProps) => void;
@@ -451,38 +451,16 @@
451
451
  /** Modal background - Shouldn't be under the .bs class */
452
452
 
453
453
  .modal-backdrop {
454
- position: fixed;
455
- top: 0;
456
- left: 0;
457
- z-index: $zindex-modal-backdrop;
458
- width: 100vw;
459
- height: 100vh;
460
- background-color: $modal-backdrop-bg;
461
- // Fade for backdrop
462
- &.fade {
463
- opacity: 0;
464
- }
465
- &.show {
466
- opacity: $modal-backdrop-opacity;
467
- }
454
+ --bs-backdrop-zindex: #{$zindex-modal-backdrop};
455
+ --bs-backdrop-bg: #{$modal-backdrop-bg};
456
+ --bs-backdrop-opacity: #{$modal-backdrop-opacity};
457
+
458
+ @include overlay-backdrop(var(--bs-backdrop-zindex), var(--bs-backdrop-bg), var(--bs-backdrop-opacity));
468
459
  }
469
460
 
470
461
 
471
462
  /** Offcanvas background - Shouldn't be under the .bs class */
472
463
 
473
464
  .offcanvas-backdrop {
474
- position: fixed;
475
- top: 0;
476
- left: 0;
477
- z-index: $zindex-offcanvas-backdrop;
478
- width: 100vw;
479
- height: 100vh;
480
- background-color: $offcanvas-backdrop-bg;
481
- // Fade for backdrop
482
- &.fade {
483
- opacity: 0;
484
- }
485
- &.show {
486
- opacity: $offcanvas-backdrop-opacity;
487
- }
488
- }
465
+ @include overlay-backdrop($zindex-offcanvas-backdrop, $offcanvas-backdrop-bg, $offcanvas-backdrop-opacity);
466
+ }