Skip to content

Commit

Permalink
reduce 5kb by compressing media queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sphinxrave committed Jul 18, 2024
1 parent d8e816d commit efc1450
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 31 deletions.
40 changes: 40 additions & 0 deletions packages/react/grep-icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import re
from collections import defaultdict

def extract_icons(directory):
icons = defaultdict(set)
pattern = r'i-(?:\w|-|_)+:(?:\w|-|_)+'

for root, _, files in os.walk(directory):
for file in files:
if file.endswith(('.js', '.jsx', '.ts', '.tsx')):
file_path = os.path.join(root, file)
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
matches = re.findall(pattern, content)
for match in matches:
icons[match].add(file_path)

return icons

# Usage
src_directory = './src' # Replace with your src directory path
extracted_icons = extract_icons(src_directory)

# Print the extracted icons and their associated files
for icon, files in sorted(extracted_icons.items()):
print(f"Icon: {icon}")
for file in sorted(files):
print(f" - {file}")
print()

# Write the icons and their files to a text file
with open('extracted_icons_with_files.txt', 'w') as f:
for icon, files in sorted(extracted_icons.items()):
f.write(f"Icon: {icon}\n")
for file in sorted(files):
f.write(f" - {file}\n")
f.write("\n")

print(f"Extracted {len(extracted_icons)} icons. Results saved to 'extracted_icons_with_files.txt'")
72 changes: 45 additions & 27 deletions packages/react/package-lock.json

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

1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"lightningcss": "^1.25.1",
"lint-staged": "^15.2.2",
"postcss": "^8.4.38",
"postcss-combine-media-query": "^1.0.1",
"postcss-import": "^16.1.0",
"postcss-import-ext-glob": "^2.1.1",
"postcss-input-range": "^5.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/react/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default {
"postcss-import-ext-glob": {},
"postcss-import": {},
"postcss-input-range": {},
"postcss-combine-media-query": {},
},
};
7 changes: 4 additions & 3 deletions packages/react/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ export function Sidebar() {
<Link
to="/settings/orgs"
className={cn(
"w-full justify-start rounded-md px-4 py-2 text-center text-sm font-semibold tracking-tight text-base-9 transition-opacity hover:bg-base-3",
"w-full justify-start rounded-md px-4 py-2 text-center text-sm font-semibold tracking-tight text-base-9 transition-opacity duration-300 hover:bg-base-3",
{
"visible opacity-70": fs,
"opacity-0 group-hover/sidebar:opacity-70": !fs,
"opacity-0 group-hover/sidebar:opacity-50 hover:!opacity-80":
!fs,
},
)}
style={{
//dotted border:
border: "1px dashed var(--base-4)",
border: "2px dashed var(--base-4)",
}}
>
Change Starred Orgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { localeAtom, preferredTimezonesAtom } from "@/store/i18n";
import { VideoCardType } from "./VideoCard";
import type { Dayjs } from "dayjs";

let incr = 0;

export function VideoCardCountdownToLive({
video,
className,
Expand Down Expand Up @@ -46,7 +48,7 @@ export function VideoCardCountdownToLive({
</span>
)}
{formatTimeForTimezones(timestamp).map(({ timezone, time }) => (
<div key={id + timezone} className="">
<div key={id + timezone + incr++} className="">
<div className="text-base-9">{timezone}:</div>
<div className="text-center text-sm font-semibold text-base-11">
{time}
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ i18n
});

i18n.on("languageChanged", async (lng: SupportedLangCodes) => {
console.log("Dayjs Language changing to", lng);
if (lng === "en") return;
const localeCode = await loadDayJsLocale(lng);

store.set(localeAtom, {
Expand Down

0 comments on commit efc1450

Please sign in to comment.