Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
43 changes: 43 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';

export default [
{
ignores: ['node_modules/**', 'templates/**', 'gulpfile.js', 'css/**', 'eslint.config.js'],
},
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'script',
globals: {
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
console: 'readonly',
},
},
plugins: {
prettier: prettierPlugin,
},
rules: {
'prettier/prettier': ['error'],
'no-use-before-define': ['error', { functions: false, classes: false }],
'no-param-reassign': ['warn'],
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'max-len': [
'error',
{
code: 150,
ignoreTemplateLiterals: true,
ignoreStrings: true,
},
],
'no-shadow': ['error'],
'no-plusplus': ['off'],
'no-mixed-operators': ['error'],
},
},
eslintConfigPrettier,
];
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div class="scroll-show">
<div class="white-bg"></div>
<div class="site-logo">
<a href="/"><img src="images/nigerialogos_logo.svg" alt="NigeriaLogos logo"></a>
<a href="/"><img src="images/NigeriaLogos_logo.svg" alt="NigeriaLogos logo"></a>
</div>
<div class="secondary-alphabet"><a href="##">#</a></div>
<div class="searchbar">
Expand All @@ -72,7 +72,7 @@
</div>
<div class="heading">
<div class="site-logo">
<a href="/"><img src="images/nigerialogos_logo.svg" alt="NigeriaLogos logo"></a>
<a href="/"><img src="images/NigeriaLogos_logo.svg" alt="NigeriaLogos logo"></a>
</div>
<h1>NigeriaLogos, an <a href="https://github.com/PaystackHQ/nigerialogos" target="_blank">open source</a>
collection<br>of high quality, pixel perfect Nigerian<br>company logos for free use.</h1>
Expand Down
14 changes: 7 additions & 7 deletions js/imageLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const loadJSON = callback => {
};

const sortObjectArray = (array, key) => {
return array.sort(function(a1, a2) {
return array.sort(function (a1, a2) {
const b1 = a1[key].toLowerCase();
const b2 = a2[key].toLowerCase();

Expand All @@ -32,12 +32,12 @@ const sortObjectArray = (array, key) => {

const isValidURL = url => {
let urlInstance;
try {
urlInstance = new URL(url);
} catch (_) {
return false;
}
return urlInstance.protocol === "http:" || urlInstance.protocol === "https:";
try {
urlInstance = new URL(url);
} catch (_) {
return false;
}
return urlInstance.protocol === 'http:' || urlInstance.protocol === 'https:';
};

const setLogoCompanyLink = logoArray => {
Expand Down
29 changes: 14 additions & 15 deletions js/mobileDownload.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
window.addEventListener('load', ()=> {
const links = document.querySelectorAll('.logo__download__overlay a');
let clicks = 0;
const stopLink = function (e) {
clicks ++;
// Prevent download on first clicks so as to enable hover effect on mobile
if (clicks % 2 !== 0) e.preventDefault();

}
if ('ontouchstart' in window || 'ontouch' in window) {
links.forEach(link => {
link.addEventListener('click', stopLink);
})
}
})
window.addEventListener('load', () => {
const links = document.querySelectorAll('.logo__download__overlay a');
let clicks = 0;
const stopLink = function (e) {
clicks++;
// Prevent download on first clicks so as to enable hover effect on mobile
if (clicks % 2 !== 0) e.preventDefault();
};
if ('ontouchstart' in window || 'ontouch' in window) {
links.forEach(link => {
link.addEventListener('click', stopLink);
});
}
});
2 changes: 1 addition & 1 deletion js/scroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function() {
(function () {
const main = document.querySelector('main');
const scrollShow = document.querySelector('.scroll-show');
const secondaryAlphabet = document.querySelector('.secondary-alphabet');
Expand Down
53 changes: 24 additions & 29 deletions js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,33 @@ const updateSearchState = () => {

// Escape meta-characters to prevent DOM->HTML XSS
function escapeHtml(text) {
return text
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#39;");
return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
}

const highlightSearchTerm = (logo, term) => {
const logoText = logo.querySelector('.logo__text--link');
const logoTextTitle = logoText.textContent;
if (!term) {
logoText.innerHTML = escapeHtml(logoTextTitle);
return;
}
// Escape and highlight term
// Use a global, case-insensitive regex
// We escape fragments, but wrap matches in <mark>
const regex = new RegExp(term, 'gi');
let lastIndex = 0;
let html = '';
let match;
while ((match = regex.exec(logoTextTitle)) !== null) {
// Escape the text before the match
html += escapeHtml(logoTextTitle.substring(lastIndex, match.index));
// Highlight the match (escape just in case)
html += `<mark>${escapeHtml(match[0])}</mark>`;
lastIndex = regex.lastIndex;
}
// Escape the rest after last match
html += escapeHtml(logoTextTitle.substring(lastIndex));
logoText.innerHTML = html;
const logoText = logo.querySelector('.logo__text--link');
const logoTextTitle = logoText.textContent;
if (!term) {
logoText.innerHTML = escapeHtml(logoTextTitle);
return;
}
// Escape and highlight term
// Use a global, case-insensitive regex
// We escape fragments, but wrap matches in <mark>
const regex = new RegExp(term, 'gi');
let lastIndex = 0;
let html = '';
let match;
while ((match = regex.exec(logoTextTitle)) !== null) {
// Escape the text before the match
html += escapeHtml(logoTextTitle.substring(lastIndex, match.index));
// Highlight the match (escape just in case)
html += `<mark>${escapeHtml(match[0])}</mark>`;
lastIndex = regex.lastIndex;
}
// Escape the rest after last match
html += escapeHtml(logoTextTitle.substring(lastIndex));
logoText.innerHTML = html;
};

const onSearch = e => {
Expand Down
6 changes: 3 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

[[redirects]]
from = "/logos.json"
to = "https://cdn.statically.io/gh/PaystackHQ/nigerialogos@master/logos.json"
to = "https://cdn.jsdelivr.net/gh/PaystackHQ/nigerialogos@master/logos.json"
status = 301
force = true

[[redirects]]
from = "/logos/*"
to = "https://cdn.statically.io/gh/PaystackHQ/nigerialogos@master/logos/:splat"
to = "https://cdn.jsdelivr.net/gh/PaystackHQ/nigerialogos@master/logos/:splat"
status = 301
force = true

[[redirects]]
from = "/images/*"
to = "https://cdn.statically.io/gh/PaystackHQ/nigerialogos@master/images/:splat"
to = "https://cdn.jsdelivr.net/gh/PaystackHQ/nigerialogos@master/images/:splat"
status = 301
force = true
Loading
Loading