Skip to content

Commit

Permalink
Install biome and run format
Browse files Browse the repository at this point in the history
  • Loading branch information
brehen committed Nov 19, 2024
1 parent e195388 commit ee8533b
Show file tree
Hide file tree
Showing 21 changed files with 377 additions and 338 deletions.
40 changes: 40 additions & 0 deletions capra-fagradar/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"json": {
"formatter": {
"enabled": true
}
},
"css": {
"formatter": {
"enabled": true
}
}
}
42 changes: 19 additions & 23 deletions capra-fagradar/csv_to_mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,40 @@ import fs from 'fs';
const csv_filename = process.argv[2];
const output_dir = process.argv[3];

if(!fs.existsSync(csv_filename)) {
if (!fs.existsSync(csv_filename)) {
console.log(`Couldn't find file "${csv_filename}"`);
process.exit(1);
}

if(!output_dir) {
console.log("No output dir set");
if (!output_dir) {
console.log('No output dir set');
process.exit(1);
}

const data = fs.readFileSync(csv_filename, { encoding: 'utf8', flag: 'r' });

const csv_to_json = (csv_content) => {
const lines = csv_content
.split("\n")
.map(line => {
const regex = /(\"[^\"]*\"[^,]*|[^,\"]+)/g;
return line.match(regex);
});
const lines = csv_content.split('\n').map((line) => {
const regex = /(\"[^\"]*\"[^,]*|[^,\"]+)/g;
return line.match(regex);
});
const headers = lines[0];

return lines
.slice(1)
.filter(line => line !== null)
.map(line => {
.filter((line) => line !== null)
.map((line) => {
let new_obj = {};
headers.forEach((header, i) => {
header = header.toLowerCase();
if(header == 'isnew')
header = 'is_new';
if (header == 'isnew') header = 'is_new';

if(typeof line[i] !== 'undefined') {
if(line[i] === "FALSE") {
if (typeof line[i] !== 'undefined') {
if (line[i] === 'FALSE') {
new_obj[header] = false;
} else if(line[i] === "TRUE") {
} else if (line[i] === 'TRUE') {
new_obj[header] = true;
} else if(line[i] === "ja") {
} else if (line[i] === 'ja') {
new_obj[header] = true;
} else {
new_obj[header] = line[i];
Expand All @@ -49,13 +46,13 @@ const csv_to_json = (csv_content) => {
});
return new_obj;
});
}
};

const json = csv_to_json(data);

//console.log(JSON.stringify(json));

json.forEach(entry => {
json.forEach((entry) => {
const name = entry.name
.toLowerCase()
.replace(' ', '-')
Expand All @@ -70,9 +67,8 @@ json.forEach(entry => {
.replace(':', '')
.replace('.', '')
.replace('"', '');
const filename = `${output_dir}/${name}.mdx`
const data =
`---
const filename = `${output_dir}/${name}.mdx`;
const data = `---
id:
name: ${entry.name}
depth: ${entry.ring}
Expand All @@ -82,7 +78,7 @@ date: ${entry.date}
---
${entry.description}
`
`;
fs.writeFileSync(filename, data);
console.log(`Written file ${filename}`);
});
67 changes: 34 additions & 33 deletions capra-fagradar/package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
{
"name": "capra-fagradar",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview",
"test": "echo 'no test'",
"typecheck": "tsc -b"
},
"dependencies": {
"@fontsource-variable/inter": "^5.0.20",
"d3-scale": "^4.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.0",
"react-tooltip": "^5.28.0",
"zustand": "^5.0.1"
},
"devDependencies": {
"@mdx-js/rollup": "^3.0.1",
"@types/mdx": "^2.0.13",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"remark-mdx-frontmatter": "^5.0.0",
"typescript": "^5.2.2",
"vite": "^5.3.4"
},
"packageManager": "[email protected]+sha512.dc09430156b427f5ecfc79888899e1c39d2d690f004be70e05230b72cb173d96839587545d09429b55ac3c429c801b4dc3c0e002f653830a420fa2dd4e3cf9cf"
"name": "capra-fagradar",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview",
"test": "echo 'no test'",
"typecheck": "tsc -b"
},
"dependencies": {
"@fontsource-variable/inter": "^5.0.20",
"d3-scale": "^4.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.0",
"react-tooltip": "^5.28.0",
"zustand": "^5.0.1"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@mdx-js/rollup": "^3.0.1",
"@types/mdx": "^2.0.13",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"remark-mdx-frontmatter": "^5.0.0",
"typescript": "^5.2.2",
"vite": "^5.3.4"
},
"packageManager": "[email protected]+sha512.dc09430156b427f5ecfc79888899e1c39d2d690f004be70e05230b72cb173d96839587545d09429b55ac3c429c801b4dc3c0e002f653830a420fa2dd4e3cf9cf"
}
8 changes: 4 additions & 4 deletions capra-fagradar/src/app.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
body {
margin: 0;
padding: 0;
background: #E4FBF5;
font-family: 'Inter Variable', sans-serif;
background: #e4fbf5;
font-family: "Inter Variable", sans-serif;
}

.header {
background: #121C31;
background: #121c31;
padding: 1rem 2rem;
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -40,7 +40,7 @@ body {
}

.footer {
background: #121C31;
background: #121c31;
padding: 2rem;
display: flex;
flex-direction: row;
Expand Down
56 changes: 28 additions & 28 deletions capra-fagradar/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { Outlet, Link } from "react-router-dom";
import style from "./app.module.css";
import { Breadcrumb } from "./breadcrumb";
import { Header } from "./header";
import { Footer } from "./footer";
import { Outlet, Link } from 'react-router-dom';
import style from './app.module.css';
import { Breadcrumb } from './breadcrumb';
import { Header } from './header';
import { Footer } from './footer';

export const App = () => {
return (
<div>
<Header />
<main>
<Breadcrumb />
<Outlet />
</main>
<Footer />
</div>
);
return (
<div>
<Header />
<main>
<Breadcrumb />
<Outlet />
</main>
<Footer />
</div>
);
};

const HalfWidthSection : React.FC<React.PropsWithChildren> = ({ children }) => {
return <section className={style.halfWidthSection}>{children}</section>;
const HalfWidthSection: React.FC<React.PropsWithChildren> = ({ children }) => {
return <section className={style.halfWidthSection}>{children}</section>;
};

export const MainPage = () => {
return (
<>
<h2> Capra sine fagradarer </h2>
<HalfWidthSection>
<Link to="/technical-radar/">Teknisk radar</Link>
</HalfWidthSection>
<HalfWidthSection>
<Link to="/tech-leader-radar/">Teknologiledelse radar</Link>
</HalfWidthSection>
</>
);
return (
<>
<h2> Capra sine fagradarer </h2>
<HalfWidthSection>
<Link to="/technical-radar/">Teknisk radar</Link>
</HalfWidthSection>
<HalfWidthSection>
<Link to="/tech-leader-radar/">Teknologiledelse radar</Link>
</HalfWidthSection>
</>
);
};
20 changes: 10 additions & 10 deletions capra-fagradar/src/breadcrumb/breadcrumb.module.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.breadcrumb {
list-style-type: none;
margin: 0;
padding: 0;
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
gap: 0.3rem;
font-size: 0.9rem;
}

.breadcrumb > * + *::before {
content:"\A";
width:0.5em;
height:0.5em;
border-radius:50%;
background: #4a4a4a;
display:inline-block;
margin:0 0.4rem;
content: "\A";
width: 0.5em;
height: 0.5em;
border-radius: 50%;
background: #4a4a4a;
display: inline-block;
margin: 0 0.4rem;
}
26 changes: 13 additions & 13 deletions capra-fagradar/src/breadcrumb/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import style from "./breadcrumb.module.css";
import { useMatches } from "react-router-dom";
import style from './breadcrumb.module.css';
import { useMatches } from 'react-router-dom';

export const Breadcrumb = () => {
const matches = useMatches();
const crumbs = (matches as { handle: { crumb?: Function }}[])
.filter((match) => typeof match.handle?.crumb === 'function')
.map((match) => (match.handle as any).crumb);
const matches = useMatches();
const crumbs = (matches as { handle: { crumb?: Function } }[])
.filter((match) => typeof match.handle?.crumb === 'function')
.map((match) => (match.handle as any).crumb);

return (
<ol className={style.breadcrumb}>
{crumbs.map((Crumb, index) => (
<li key={index}>
return (
<ol className={style.breadcrumb}>
{crumbs.map((Crumb, index) => (
<li key={index}>
<Crumb />
</li>
))}
</ol>
);
))}
</ol>
);
};
20 changes: 10 additions & 10 deletions capra-fagradar/src/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import style from "./app.module.css";
import Logo from "./logo";
import style from './app.module.css';
import Logo from './logo';

export const Footer = () => {
return (
<footer className={style.footer}>
<Logo />
<div>
<a href="https://capraconsulting.no">Tilbake til capraconsulting.no</a>
</div>
</footer>
);
return (
<footer className={style.footer}>
<Logo />
<div>
<a href="https://capraconsulting.no">Tilbake til capraconsulting.no</a>
</div>
</footer>
);
};
Loading

0 comments on commit ee8533b

Please sign in to comment.