Skip to content

a javascript library for creating Navbar UI, from a json {...} file/object array. it came also with colors.

Notifications You must be signed in to change notification settings

The-DevNinja/navColor.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

navColor.js

ezgif com-gif-maker (31)

how to install it

just copy this CDN link to your <head> tag!

<script src="https://cdn.jsdelivr.net/gh/The-DevNinja/navColor.js/script.min.js" defer></script>

if you want to put it inside <head> add a defer attribute to the <script> tag
otherway, you need to put the script before calling the function, for not getting bugs :)


YouTube Video Tutorial Online Website
https://youtu.be/KxA1_yTOFHw https://navcolorjs.vercel.app/

table of contents:


how to configure

where should I paste the function()?

you need to add this function to your <script> tag, or in your .js javascript file.

what is the name of the function?

the function is createNav();

what is the order of the parameters?

  1. the first parameter is a array of objects
  2. the second parameter is not necessary, but is only needed for more custum navbar functionality.

the syntax will look like this:

createNav([{...}, {...}, {...}], options);

what I need to put inside the object {...}?

the object need 3 parameters:

the order of parameters not affect the functionality)

1 iconName first parameter

something like this:

{
    iconName: "fa-user",
    // other parameters
}

this project under the hood uses fontawesome icons library.

so you need to write a string containing the class of that icon.

Immagine 2022-07-15 000013

2 color second parameter

the color need to be a string containing one of the following values:

  1. hex, for example: #00FFFF (remember to add #)
  2. or a rgb(), for example: rgb(0,0, 255)
  3. or normal color value for example: cyan
  4. or any other valid css color value (but in string format)

something like this:

{
    color: "cyan",
    // other parameters
}

3 text third parameter

this is the text that will be displayed onclick of a icon.

also this need to be a string

something like this:

{
    text: "hello world!",
    // other parameters
}

example code object

this is a example containing 3 objects in array, without any options.

createNav([{    // first 
        "text": "homepage page",
        "iconName": "fa-building",
        "color": "red"
    },          // second 
    {   "text": "see your files",
        "iconName": "fa-file-code",
        "color": "blue"
    },          // third
    {   "text": "your profile",
        "iconName": "fa-user",
        "color": "yellow"
    }]
);

if you don't like writing directly the array, then do like this:

const myArray = [
    {
        "text": "homepage page",
        "iconName": "fa-building",
        "color": "red"
    },
    {
        "text": "see your files",
        "iconName": "fa-file-code",
        "color": "blue"
    }, 
    {
        "text": "your profile",
        "iconName": "fa-user",
        "color": "yellow"
    }
];

createNav(myArray); // this is also working fine!

options second parameters

the options aren't important to add, use them only when you need more custum behaviurs.

if you have any ideas of a new feature to add,
you add a suggestion in the "issue" tab in this github repo. thank a lot.

you can add a <nav> with the ID or class you want?

how to add a ID?

you need to write this, with a string containing your choosed class,
make sure that there is # before the name of the id

{
    navElement: "#myId",
    // other parameters
}

// output: <nav id="myId">...</nav>

I suggest this solution than the class solution, because a ID can be added only one time, so is unique.

how to add a CLASS?

you need to write this, with a string containing your choosed class,
make sure that there is . before the name of the class

{
    navElement: ".myClass",
    // other parameters
}

// output: <nav class="myClass">...</nav>

you can disable my CSS file, to write your own custum CSS

this need a boolean value like false or true

by default is setted to false.

{
    isHtmlOnly: true,
    // other parameters
}

this make you only install the script for creating html tags,
and the CSS variables, will continue to working!
and my CSS won't be installed.

instead if you want most parts of my CSS, but not all,
you can modify only the parts you want with your css file and adding !important if it didn't work (make sure to use also devtools).

list of css selector you can use for custumizable UI
name of class description
.icon-div the parent-div that will contain
the <i> tag of the icon fontawesome
.icon-div.active you can use this selector for adding some effect after the click of a icon
.icon is the <i> tag itself, which will be the icon itself
list of css variables you can use for custumizable UI
name of class description
--bg you can use this css variable in your css code
to color correctly and dinamically anything by using var(--bg);
[data-text] this isn't a css variables but still helpful,
you can use this data-text html attribute in your pseudo-elements (::before, ::after, etc...)
with the attr(data-text) css function

About

a javascript library for creating Navbar UI, from a json {...} file/object array. it came also with colors.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages