Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add UI library and Molstar #60

Merged
merged 3 commits into from
Nov 13, 2023
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
6 changes: 6 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"@types/cookie": "^0.5.1",
"autoprefixer": "^10.4.14",
"flowbite": "^2.1.1",
"flowbite-svelte": "^0.44.19",
"openapi-typescript-codegen": "^0.25.0",
"postcss": "^8.4.24",
"postcss-load-config": "^4.0.1",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"tailwindcss": "^3.3.2",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.4.2",
Expand Down
13 changes: 13 additions & 0 deletions frontend/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const tailwindcss = require("tailwindcss");
const autoprefixer = require("autoprefixer");

const config = {
plugins: [
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
tailwindcss(),
//But others, like autoprefixer, need to run after,
autoprefixer,
],
};

module.exports = config;
10 changes: 10 additions & 0 deletions frontend/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<!-- Molstar CSS & JS -->
<link
rel="stylesheet"
type="text/css"
href="https://www.ebi.ac.uk/pdbe/pdb-component-library/css/pdbe-molstar-light-3.1.2.css"
/>
<script
type="text/javascript"
src="https://www.ebi.ac.uk/pdbe/pdb-component-library/js/pdbe-molstar-plugin-3.1.2.js"
></script>
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
4 changes: 4 additions & 0 deletions frontend/src/app.postcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Write your global styles here, in PostCSS syntax */
@tailwind base;
@tailwind components;
@tailwind utilities;
54 changes: 54 additions & 0 deletions frontend/src/lib/ProteinVis.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script lang="ts">
import { onMount } from "svelte";

export let url =
"https://alphafold.ebi.ac.uk/files/AF-O15552-F1-model_v1.cif";
export let format = "cif";

onMount(async () => {
//Create plugin instance
// @ts-ignore
var viewerInstance = new PDBeMolstarPlugin(); // loaded through app.html

//Set options (Checkout available options list in the documentation)
var options = {
customData: {
url,
format,
},
subscribeEvents: false,
bgColor: {
r: 255,
g: 255,
b: 255,
},
selectInteraction: true,
alphafoldView: true,
reactive: true,
sequencePanel: true,
hideControls: true,
hideCanvasControls: ["animation"],
};

//Get element from HTML/Template to place the viewer
var viewerContainer = document.getElementById("myViewer");

//Call render method to display the 3D view
viewerInstance.render(viewerContainer, options);
});
</script>

<div id="myViewer" />

<style>
/* https://embed.plnkr.co/plunk/WlRx73uuGA9EJbpn */
.msp-plugin ::-webkit-scrollbar-thumb {
background-color: #474748 !important;
}
#myViewer {
float: left;
width: 500px;
height: 500px;
position: relative;
}
</style>
1 change: 1 addition & 0 deletions frontend/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import "../app.postcss";
import Header from "./Header.svelte";
import "./styles.css";
</script>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/routes/protein/[proteinId]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import { onMount } from "svelte";
import { Backend, type ProteinEntry } from "$lib/backend";
import ProteinVis from "$lib/ProteinVis.svelte";
import { Spinner } from "flowbite-svelte";

export let data; // linked to +page.ts return (aka the id)
let entry: ProteinEntry | null = null;
Expand All @@ -23,9 +25,11 @@
<!-- if got entry from backend, display it -->
<h1>{entry.name}</h1>
<p>ID: {entry.id}</p>

<ProteinVis />
{:else if !error}
<!-- Otherwise, tell user we tell the user we are loading -->
<h1>Loading...</h1>
<h1>Loading Protein Entry <Spinner /></h1>
{:else if error}
<!-- if we error out, tell the user the id is shiza -->
<h1>Error</h1>
Expand Down
10 changes: 5 additions & 5 deletions frontend/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import adapter from "@sveltejs/adapter-auto";
import { vitePreprocess } from "@sveltejs/kit/vite";

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
preprocess: [vitePreprocess({})],

kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
adapter: adapter(),
},
};

export default config;
32 changes: 32 additions & 0 deletions frontend/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const config = {
content: [
"./src/**/*.{html,js,svelte,ts}",
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
],

plugins: [require("flowbite/plugin")],

darkMode: "class",

theme: {
extend: {
colors: {
// flowbite-svelte
primary: {
50: "#FFF5F2",
100: "#FFF1EE",
200: "#FFE4DE",
300: "#FFD5CC",
400: "#FFBCAD",
500: "#FE795D",
600: "#EF562F",
700: "#EB4F27",
800: "#CC4522",
900: "#A5371B",
},
},
},
},
};

module.exports = config;
Loading