Tanzeel
Tanzeel

Reputation: 4998

How to change icon of a component in HTML

(I might be asking a very stupid question). I've a requirement for our project. Here is the component: enter image description here

Yes, it is a dropdown. But is there a way to change that down arrow symbol to 3 dots? something similar to this: enter image description here

That dropdown is not the native HTML dropdown. Actually it is coming form a custom built angular library. Here's the code:

component template

<dls-dropdown>
    <dls-option class="pt-quiet three-dots-for-card">
        Apple
    </dls-option>
    <dls-option>
        Banana
    </dls-option>
</dls-dropdown>

I tried this:

Scss

.three-dots-for-card {
    border: none;
    width: 200px;
    padding-left: 170px;
    left: -170px;
    position: relative;
    z-index: 0;
    content: "...";
    .pt-layout-container {
        padding: 5px;
        button {
            display: none;
        }
        span {
            &:before {
                display: flex;
                align-items: center;
                font-family: dls-icons-24, serif;
                font-size: 24px;
                color: black;
                content: "...";
            }
        }
    }
}

But the symbol becomes blank.

P.S: My tech leach has told me not to include any other library like PrimeNg, fontAwesome, etc.

Is it even doable? Please help me if yes.

Upvotes: 0

Views: 537

Answers (2)

Sophie
Sophie

Reputation: 480

Hey I think you could create a custom dropdown, something like this:

$(document).ready(function() {
  var tableContextMenu = new ContextMenu("context-menu-items", menuItemClickListener);
});

function menuItemClickListener(menu_item, parent) {
  alert("Menu Item Clicked: " + menu_item.text());
}
.modal {
  z-index: 5000 !important;
}


p.contextMenu:after>span {
  margin: 0 !important;
  padding: 0 !important;
}
.context-menu-container {
  background-color: white;
  z-index: 1000 !important;
  border-radius: 5px;
  position: absolute;
  display: none;
  border: solid thin black;
  padding: 3px;
  -webkit-box-shadow: 4px 4px 8px 0px rgba(0, 0, 0, 0.18);
  -moz-box-shadow: 4px 4px 8px 0px rgba(0, 0, 0, 0.18);
  box-shadow: 4px 4px 8px 0px rgba(0, 0, 0, 0.18);
  min-width: 90px;
  margin-left:100px;
}

.context-menu-container>ul {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.context-menu-container>ul>li {
  padding: 5px;
  cursor: hand;
  cursor: pointer;
  border-radius: 5px;
}

.context-menu-container>ul>li:hover {
  background-color: #c4c4c4;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/paper/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://www.jqueryscript.net/demo/Material-Design-Context-Menu-jQuery-3Dot-Context-Menu/includes/context-menu.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
<div class="context-menu-container" id="context-menu-items">
  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
  </ul>
</div>

<div style="border: 1px solid #000; width:40px" class="context-menu" data-container-id="context-menu-items"><span class="material-icons">
more_horiz
</span></div>

Upvotes: 2

SIMBIOSIS surl
SIMBIOSIS surl

Reputation: 397

Try, if you can use font-awasome, something like this <i class="fab fa-youtube"></i> substituting, of course, fa-youtube with the font-awasome class for the three horizontal dots own class. Sorry but I do not have a very well knowledge about fa classes. But this should do the magic.

Upvotes: 0

Related Questions