Skip to content

Commit

Permalink
Merge branch 'next' into changeset-release/next
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge authored Oct 11, 2022
2 parents 29086fb + 9f86e39 commit 6e9ab88
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-ways-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

feat(template): add prettier.Config type to prettier config and resolve prettier-plugin-tailwindcss import
3 changes: 2 additions & 1 deletion cli/template/addons/tailwind/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @type {import("prettier").Config} */
module.exports = {
plugins: [require("prettier-plugin-tailwindcss")],
plugins: [require.resolve("prettier-plugin-tailwindcss")],
};
120 changes: 120 additions & 0 deletions www/src/components/docs/pageContent.astro
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,123 @@ const title = frontmatter.title;
block.appendChild(copyButton);
});
</script>
<script is:inline>
//FIXME: We can make this properly typed later
/**
* Allows us to animate the details element
* for it to work make sure the details element contains a summary element
* and a div element with the class of content
* @param {*} element the details element which we wish to animate
*/
const AnimateDetails = (element) => {
const summary = element.querySelector("summary");
const content = element.querySelector(".content");
let props = { animation: null, isClosing: false, isExpanding: false };

/**
* onClick event handler for the summary element
* @param {*} event the event object
*/
const onClick = (event) => {
event.preventDefault();

element.style.overflow = "hidden";

if (props.isClosing || !element.open) open();
else if (props.isExpanded || element.open) close();
};

/**
* Closes the details element
* This function is in charge of animating the closing of the
* details element
*/
const close = () => {
props.isClosing = true;

const startHeight = `${element.offsetHeight}px`;
const endHeight = `${summary.offsetHeight}px`;

if (props.animation) props.animation.cancel();

props.animation = element.animate(
{
height: [startHeight, endHeight],
},
{
duration: 300,
easing: "ease-in-out",
},
);

props.animation.onfinish = () => onAnimationFinish(false);
props.animation.oncancel = () => (props.isClosing = false);
};

/**
* Opens the details element
* requests the animation frame to animate the opening of the details element
*/
const open = () => {
element.style.height = `${summary.offsetHeight}px`;
element.open = true;
window.requestAnimationFrame(() => expand());
};

/**
* Expands the details element
* This function is in charge of animating the expansion of the
* details element
*/
const expand = () => {
props.isExpanding = true;

const startHeight = `${element.offsetHeight}px`;
const endHeight = `${content.offsetHeight + summary.offsetHeight}px`;

if (props.animation) props.animation.cancel();

props.animation = element.animate(
{
height: [startHeight, endHeight],
},
{
duration: 300,
easing: "ease-in-out",
},
);

props.animation.onfinish = () => onAnimationFinish(true);
props.animation.oncancel = () => (props.isExpanding = false);
};

/**
* Called when the animation is finished
* @param {*} open whether the details element is open or not
*/
const onAnimationFinish = (open) => {
element.open = open;
props.animation = null;
props.isClosing = false;
props.isExpanding = false;

element.style.height = element.style.overflow = "";
};

/**
* Adds our new event listener to the summary element
*/
summary.addEventListener("click", (event) => onClick(event));
};

/**
* Allows us to animate all the details elements on the page
* Will check if the details element contains a div element with the class of content
*/
const viableDetails = document.querySelectorAll("details");
viableDetails.forEach((element) => {
if (element.querySelector(".content")) {
AnimateDetails(element);
}
});
</script>
33 changes: 22 additions & 11 deletions www/src/pages/en/deployment/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Remove the `env`-import from [`next.config.mjs`](https://github.com/t3-oss/creat
<summary>
Click here and include contents in <code>.dockerignore</code>:
</summary>
<div class="content">

```
.env
Expand All @@ -51,6 +52,8 @@ README.md
.git
```

</div>

</details>

### 4. Create Dockerfile
Expand All @@ -59,6 +62,7 @@ README.md
<summary>
Click here and include contents in <code>Dockerfile</code>:
</summary>
<div class="content">

```docker
##### DEPENDENCIES
Expand All @@ -68,17 +72,19 @@ RUN apk add --no-cache libc6-compat openssl
WORKDIR /app
# Install Prisma Client - remove if not using Prisma
COPY prisma ./
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi
##### BUILDER
Expand All @@ -92,18 +98,19 @@ COPY . .
# ENV NEXT_TELEMETRY_DISABLED 1
RUN \
if [ -f yarn.lock ]; then yarn build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
if [ -f yarn.lock ]; then yarn build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
##### RUNNER
FROM --platform=linux/amd64 node:16-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
Expand All @@ -121,6 +128,7 @@ EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]
```

> **_Notes_**
Expand All @@ -129,6 +137,7 @@ CMD ["node", "server.js"]
> - _See [`node:alpine`](https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine) to understand why `libc6-compat` might be needed._
> - _Next.js collects [anonymous telemetry data about general usage](https://nextjs.org/telemetry). Uncomment the first instance of `ENV NEXT_TELEMETRY_DISABLED 1` to disable telemetry during the build. Uncomment the second instance to disable telemetry during runtime._
</div>
</details>

## Build and Run Image Locally
Expand All @@ -150,6 +159,7 @@ You can also use Docker Compose to build the image and run the container.
<summary>
Follow steps 1-4 above, click here, and include contents in <code>docker-compose.yml</code>:
</summary>
<div class="content">

```yaml
version: "3.9"
Expand Down Expand Up @@ -177,6 +187,7 @@ docker compose up

Open [localhost:3000](http://localhost:3000/) to see your running application.

</div>
</details>

## Deploy to Railway
Expand Down
16 changes: 13 additions & 3 deletions www/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@
@apply mb-0 text-sm;
}
.markdown a {
@apply text-t3-purple-500 underline decoration-slate-500 decoration-dotted underline-offset-2 hover:text-t3-purple-700 dark:text-t3-purple-200 dark:decoration-t3-purple-200 dark:hover:text-t3-purple-300;
@apply text-t3-purple-500 underline decoration-slate-500
decoration-dotted underline-offset-2
hover:text-t3-purple-700 dark:text-t3-purple-200
dark:decoration-t3-purple-200 dark:hover:text-t3-purple-300;
}
.markdown pre {
@apply my-3 mx-auto rounded-md p-2 pl-3 font-mono sm:pt-2;
Expand All @@ -159,9 +162,16 @@
}

.markdown details {
@apply w-full rounded-md bg-t3-purple-200/50 px-3 pb-0.5 dark:bg-slate-700;
@apply mt-2 w-full rounded-md bg-t3-purple-200/50 px-3 pb-0.5 ring
ring-t3-purple-200 transition-all duration-75 ease-in-out
dark:bg-slate-700 dark:ring-slate-500;
}
.markdown details > summary {
@apply cursor-pointer text-t3-purple-700 dark:text-slate-300;
}
.markdown details[open] > summary {
@apply border-b-2 border-t3-purple-200 dark:border-slate-500;
}

.markdown summary {
@apply py-3;
}
Expand Down

0 comments on commit 6e9ab88

Please sign in to comment.