Skip to content

Commit

Permalink
vertical-lr to the rescue
Browse files Browse the repository at this point in the history
  • Loading branch information
abs committed Aug 27, 2024
1 parent d7bb7c6 commit 9463493
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 21 deletions.
61 changes: 41 additions & 20 deletions storefront/src/ui/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ const SupabaseProject = ({
return (
<div className="text-black dark:text-white bg-dots w-full rounded-2xl">
<ProjectRow>
<RowHeader className="basis-1/5 md:basis-1/3">
<RowDivHeader className="basis-1/5 md:basis-1/3">
<span className="font-bold">Database</span>
</RowHeader>
</RowDivHeader>
<div>
<a
className="inline-flex items-center gap-1.5 font-medium link link-primary dark:link-secondary"
Expand All @@ -87,27 +87,27 @@ const SupabaseProject = ({
</div>
</ProjectRow>
<ProjectRow>
<RowHeader className="basis-1/5 md:basis-1/3">
<RowDivHeader className="basis-1/5 md:basis-1/3">
<span dangerouslySetInnerHTML={{ __html: nbsp("Project ref") }} />
</RowHeader>
</RowDivHeader>
<div>
<span className="font-medium break-all">{project.id}</span>
</div>
</ProjectRow>
<ProjectRow>
<RowHeader className="basis-1/5 md:basis-1/3">Version</RowHeader>
<RowDivHeader className="basis-1/5 md:basis-1/3">Version</RowDivHeader>
<div>
<span className="font-medium">{project.database?.version}</span>
</div>
</ProjectRow>
<ProjectRow>
<RowHeader className="basis-1/5 md:basis-1/3">Region</RowHeader>
<RowDivHeader className="basis-1/5 md:basis-1/3">Region</RowDivHeader>
<div>
<span className="font-medium">{project.region}</span>
</div>
</ProjectRow>
<ProjectRow>
<RowHeader className="basis-1/5 md:basis-1/3">Status</RowHeader>
<RowDivHeader className="basis-1/5 md:basis-1/3">Status</RowDivHeader>
<div>
<span
className={classNames("flex gap-2 flex-col md:flex-row", "font-medium", {
Expand Down Expand Up @@ -135,7 +135,7 @@ const SupabaseProject = ({
</div>
</ProjectRow>
<ProjectRow>
<RowHeader className="basis-1/5 md:basis-1/3">Created</RowHeader>
<RowDivHeader className="basis-1/5 md:basis-1/3">Created</RowDivHeader>
<div>
<span className="inline-block font-medium first-letter:capitalize">
{dayjs(project.created_at).fromNow()}
Expand Down Expand Up @@ -263,12 +263,15 @@ const SupafanaProject = ({
<table className="text-gray-200 dark:text-gray-700 bg-dots table">
<tbody className="text-black dark:text-white">
<tr>
<RowHeader>
<RowTdHeader>
<span className="font-bold">Grafana</span>
</RowHeader>
</RowTdHeader>
<td colSpan={state === "Running" ? 1 : 2}>
<a
className="inline-flex items-center gap-1.5 font-medium link link-primary dark:link-secondary"
className={classNames(
"inline-flex items-center gap-1.5 font-medium link link-primary dark:link-secondary",
state === "Running" && "vertical-rl sm:horizontal-tb"
)}
href={`/dashboard/${project.id}/`}
title={`Open ${project.name} in Supafana`}
target="_blank"
Expand All @@ -293,9 +296,9 @@ const SupafanaProject = ({
)}
</tr>
<tr>
<RowHeader>State</RowHeader>
<RowTdHeader>State</RowTdHeader>
<td>
<span className="font-medium break-all">{state}</span>
<span className="font-medium vertical-rl sm:horizontal-tb">{state}</span>
</td>
{state === "Running" && (
<td>
Expand Down Expand Up @@ -361,19 +364,23 @@ const SupafanaProject = ({
</tr>
{plan !== "Trial" && (
<tr>
<RowHeader>Plan</RowHeader>
<td>
<RowTdHeader>Plan</RowTdHeader>
<td colSpan={2}>
<span className="font-medium break-all">{plan}</span>
</td>
</tr>
)}
{plan === "Trial" && grafana.first_start_at && (
<tr>
{trialEnded ? <RowHeader>Trial ended</RowHeader> : <RowHeader>Trial ends</RowHeader>}
{trialEnded ? (
<RowTdHeader>Trial ended</RowTdHeader>
) : (
<RowTdHeader>Trial ends</RowTdHeader>
)}
<td>
<span
key={grafana.trial_remaining_msec}
className="inline-block font-medium break-all first-letter:capitalize"
className="inline-block font-medium break-all first-letter:capitalize vertical-rl sm:horizontal-tb"
>
{dayjs(grafana.first_start_at).add(grafana.trial_length_min, "minute").fromNow()}
</span>
Expand Down Expand Up @@ -404,15 +411,15 @@ const SupafanaProject = ({
*/}
{created && (
<tr>
<RowHeader>Created</RowHeader>
<RowTdHeader>Created</RowTdHeader>
<td colSpan={2}>
<span className="inline-block font-medium first-letter:capitalize">{created}</span>
</td>
</tr>
)}
{grafana.state === "Running" && (
<tr>
<RowHeader>User/pass</RowHeader>
<RowTdHeader>User/pass</RowTdHeader>
<td>
<span className="font-medium">
<code>admin</code>
Expand Down Expand Up @@ -440,7 +447,21 @@ const ProjectRow = ({ children }: { children: JSX.Element[] }) => {
);
};

const RowHeader = ({
const RowTdHeader = ({
children,
className,
}: {
children: JSX.Element | string;
className?: string;
}) => {
return (
<td className={classNames(className)}>
<span className="text-gray-500 dark:text-gray-300">{children}</span>
</td>
);
};

const RowDivHeader = ({
children,
className,
}: {
Expand Down
22 changes: 21 additions & 1 deletion storefront/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('tailwindcss').Config} */
const plugin = require("tailwindcss/plugin");

module.exports = {
presets: [require("./src/supafana.tailwind.preset.js")],
content: [
Expand All @@ -19,5 +21,23 @@ module.exports = {
}),
},
},
plugins: [require("@tailwindcss/custom-forms"), require("@tailwindcss/typography")],
plugins: [
require("@tailwindcss/custom-forms"),
require("@tailwindcss/typography"),
// https://github.com/tailwindlabs/tailwindcss/discussions/2494#discussion-22808
plugin(function ({ addUtilities, addComponents, e, prefix, config }) {
const newUtilities = {
".horizontal-tb": {
writingMode: "horizontal-tb",
},
".vertical-rl": {
writingMode: "vertical-rl",
},
".vertical-lr": {
writingMode: "vertical-lr",
},
};
addUtilities(newUtilities);
}),
],
};

0 comments on commit 9463493

Please sign in to comment.