-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(anchor): add proper styling, support for colors, and basic test
fixes #14777
- Loading branch information
1 parent
9d0d9bf
commit 1dbf5bb
Showing
5 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
@import "../../themes/ionic.globals"; | ||
|
||
// Anchor | ||
// -------------------------------------------------- | ||
|
||
:host { | ||
// default background / color | ||
--background: transparent; | ||
--color: #{ion-color(primary, base)}; | ||
|
||
--text-decoration: none; | ||
|
||
background: var(--background); | ||
color: var(--color); | ||
|
||
text-decoration: var(--text-decoration); | ||
} | ||
|
||
:host(.ion-color) { | ||
--color: #{current-color(base)}; | ||
} | ||
|
||
a { | ||
@include text-inherit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> | ||
<html dir="ltr"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Anchor - Basic</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> | ||
<script src="/dist/ionic.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/css/ionic.min.css"> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
|
||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Anchor - Basic</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content padding> | ||
<p> | ||
<a href="#">A</a> | ||
</p> | ||
|
||
<p> | ||
<ion-anchor href="#">Anchor</ion-anchor> | ||
</p> | ||
|
||
<p> | ||
<ion-anchor href="#" class="underline">Underline Anchor</ion-anchor> | ||
</p> | ||
|
||
<p> | ||
<ion-anchor color="dark" href="#">Dark Anchor</ion-anchor> | ||
</p> | ||
|
||
<p> | ||
<ion-anchor color="danger" href="#">Danger Anchor</ion-anchor> | ||
</p> | ||
|
||
<p> | ||
<ion-anchor id="toggleColor" color="tertiary" href="#">Dynamic Color</ion-anchor> | ||
</p> | ||
|
||
<ion-button onclick="toggleColor()">Toggle Color</ion-button> | ||
</ion-content> | ||
|
||
|
||
</ion-app> | ||
|
||
<script> | ||
const el = document.querySelector('#toggleColor'); | ||
|
||
function toggleColor() { | ||
const prev = el.getAttribute('color'); | ||
el.setAttribute('color', prev === 'secondary' ? 'tertiary' : 'secondary'); | ||
el.innerHTML = prev === 'secondary' ? 'Tertiary Anchor' : 'Secondary Anchor'; | ||
} | ||
</script> | ||
|
||
<style> | ||
.underline { | ||
--text-decoration: underline; | ||
} | ||
</style> | ||
</body> | ||
|
||
</html> |