File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212### Added
1313
1414- Badge class
15- - Button class
15+ - Button class
16+ - Link class
Original file line number Diff line number Diff line change @@ -123,3 +123,38 @@ export class Button {
123123 }
124124}
125125
126+ export class Link {
127+ constructor ( config ) {
128+ // Create Link
129+ const newLink = document . createElement ( 'a' ) ;
130+ newLink . classList . add ( 'link' ) ;
131+ newLink . innerText = config . text ;
132+
133+ // Setup Size
134+ if ( config . size != null ) {
135+ newLink . classList . add ( 'link-' + config . size ) ;
136+ }
137+
138+ // Setup Style
139+ if ( config . style != null ) {
140+ newLink . classList . add ( 'link-' + config . style ) ;
141+ }
142+
143+ // Setup title
144+ if ( config . title != null ) {
145+ newLink . title = config . title ;
146+ }
147+
148+ // Setup href
149+ if ( config . href != null ) {
150+ newLink . href = config . href ;
151+ }
152+
153+ // Append to parent element
154+ if ( config . parent != null ) {
155+ document . querySelector ( config . parent ) . appendChild ( newLink ) ;
156+ } else {
157+ document . body . appendChild ( newLink ) ;
158+ }
159+ }
160+ }
You can’t perform that action at this time.
0 commit comments