Skip to content

Commit

Permalink
Merge pull request #579 from gselderslaghs/cards-buttons-mixin
Browse files Browse the repository at this point in the history
enhancement(Cards) buttons mixin implementation + auto init
  • Loading branch information
wuda-io authored Jan 30, 2025
2 parents 3321da9 + 3c930db commit dce1c7f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
37 changes: 33 additions & 4 deletions sass/components/_cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@
border-radius: 0 0 2px 2px;
}

border-top: 1px solid var(--md-sys-color-outline-variant);
position: relative;
background-color: inherit;
// position: relative;
padding: 0 1.6rem;
// border-top: 1px solid var(--md-sys-color-outline-variant);
// background-color: inherit;

a {
// Replaced card links with buttons (Accessibility, @see https://github.com/materializecss/materialize/issues/565)
/*a {
padding: 16px 24px;
display: inline-block;
}
Expand All @@ -187,6 +189,33 @@
&:hover {
background-color: rgba(var(--md-sys-color-primary-numeric), 0.06);
}
}*/

a {
@include btn(
var(--btn-height),
var(--btn-border-radius),
var(--btn-padding),
var(--btn-padding),
var(--btn-font-size)
);

&:first-child {
margin-left: -1.6rem;
}

&:last-child {
margin-right: -1.6rem;
}
}

.btn {
&.filled,
&.tonal,
&.elevated,
&.outlined {
margin: 0 .26rem 1.6rem 0;
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,15 @@ export class Cards extends Component<CardsOptions> implements Openable {
}
this._removeRevealCloseEventHandlers();
};

static Init() {
if (typeof document !== 'undefined')
// Handle initialization of static cards.
document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.card');
cards.forEach((el) => {
if (el && (el['M_Card'] == undefined)) this.init((el as HTMLElement));
});
});
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ Forms.Init();
Chips.Init();
Waves.Init();
Range.Init();
Cards.Init();

0 comments on commit dce1c7f

Please sign in to comment.