Skip to content

Commit

Permalink
Fix grid spacing on centered top sites
Browse files Browse the repository at this point in the history
  • Loading branch information
hkamran80 committed Oct 29, 2021
1 parent 07b3558 commit f7bd10a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,17 @@ function loadTopSites(): void {
limit: maxTopSites,
})
.then((topSites) => {
if (
topSitesContainer &&
topSitesContainer.id === "topSitesCenter"
) {
topSitesContainer.classList.add(
topSites.length >= 1 && topSites.length < 5
? `grid-cols-${topSites.length}`
: "grid-cols-5"
);
}

topSites.forEach((site) => {
const a = document.createElement("a");
a.href = site.url;
Expand All @@ -380,6 +391,17 @@ function loadTopSites(): void {
});
} else {
browser.topSites.get().then((topSites) => {
if (
topSitesContainer &&
topSitesContainer.id === "topSitesCenter"
) {
topSitesContainer.classList.add(
topSites.length >= 1 && topSites.length < 5
? `grid-cols-${topSites.length}`
: "grid-cols-5"
);
}

topSites.slice(0, maxTopSites).forEach((site) => {
const a = document.createElement("a");
a.href = site.url;
Expand Down
6 changes: 4 additions & 2 deletions src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
<div
id="topSitesCenter"
class="
flex
space-x-4
grid
gap-4
place-items-center
align-middle
justify-center
transition-opacity
duration-300
Expand Down
5 changes: 4 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const defaultTheme = require("tailwindcss/defaultTheme");

module.exports = {
mode: "jit",
purge: ["./src/*.{html,css,ts}"],
purge: {
content: ["./src/*.{html,css,ts}"],
safeList: ["grid-cols-1", "grid-cols-2", "grid-cols-3", "grid-cols-4"],
},
theme: {
fontFamily: {
sans: ["Quicksand", ...defaultTheme.fontFamily.sans],
Expand Down

0 comments on commit f7bd10a

Please sign in to comment.