Skip to content

Commit b116a23

Browse files
authored
feat: static import of img source (gitbutlerapp#52)
1 parent 5da8036 commit b116a23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+99
-76
lines changed

app/components/ImageSection.tsx

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
import { ImageZoom } from "fumadocs-ui/components/image-zoom"
22

33
interface Props {
4-
width: number
5-
height: number
4+
/**
5+
* Image path relative to `/public/img/docs`
6+
*/
67
src: string
78
alt?: string
89
className?: string
910
subtitle?: string
1011
}
1112

12-
export default function ImageSection({ src, alt, subtitle }: Props) {
13+
const shimmer = (w: number, h: number) => `
14+
<svg width="${w}" height="${h}" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
15+
<defs>
16+
<linearGradient id="g">
17+
<stop stop-color="#333" offset="20%" />
18+
<stop stop-color="#222" offset="50%" />
19+
<stop stop-color="#333" offset="70%" />
20+
</linearGradient>
21+
</defs>
22+
<rect width="${w}" height="${h}" fill="#333" />
23+
<rect id="r" width="${w}" height="${h}" fill="url(#g)" />
24+
<animate xlink:href="#r" attributeName="x" from="-${w}" to="${w}" dur="1s" repeatCount="indefinite" />
25+
</svg>`
26+
27+
const toBase64 = (str: string) =>
28+
typeof window === "undefined" ? Buffer.from(str).toString("base64") : window.btoa(str)
29+
30+
export default async function ImageSection({ src, alt, subtitle }: Props) {
31+
const img = await import(`../../public/img/docs${src}`).then((mod) => mod.default)
32+
if (!img) return null
33+
1334
return (
1435
<div className="mx-auto mb-4 flex flex-col justify-start rounded-lg border border-neutral-200 bg-neutral-100 p-2 dark:border-neutral-800 dark:bg-neutral-900 [&>span]:w-fit [&_img]:m-0">
1536
<ImageZoom
16-
width="0"
17-
height="0"
18-
className="h-auto w-full rounded-md"
19-
sizes="(min-width: 800px) 50vw, 100vw"
37+
className="rounded-md"
38+
placeholder={`data:image/svg+xml;base64,${toBase64(shimmer(img.width, img.height))}`}
2039
alt={alt ?? subtitle ?? ""}
21-
src={src}
40+
src={img}
2241
/>
2342
{subtitle ? (
2443
<div className="mx-auto mt-2 flex-shrink whitespace-normal text-pretty break-words text-center text-xs opacity-50">

content/docs/features/stacked-branches.mdx

+16-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This is useful when you have multiple changesets that depend on each other but i
1414

1515
> All of the Pull Request stack orchestration is done locally in the client, which means that your repo content is not shared with a cloud service.
1616
17-
<ImageSection className="mx-auto" src="/img/docs/stacked-branches/0_concepts.jpg" />
17+
<ImageSection className="mx-auto" src="/stacked-branches/0_concepts.jpg" />
1818

1919
## Use cases
2020

@@ -47,12 +47,12 @@ Stacking and Virtual Branches are similar in that they allow you to separate cod
4747
the changes are available in your working directory.
4848

4949
The main difference is that Virtual Branches are **independent** from one another, while stacked branches **depend** on the ones that come before it.
50-
Because of this, the two features are not mutually exclusive but rather complementary. For example a bugfix change that is unrelated to a feature
50+
Because of this, the two features are not mutually exclusive but rather complementary. For example a bugfix change that is unrelated to a feature
5151
can be put in a separate virtual branch. On the other hand, a change that depends on a previous change can be put in a stacked branch above the one it depends on.
5252

5353
In fact GitButler implements stacked branches as Virtual Branches that are split into multiple dependent branches.
5454

55-
<ImageSection src="/img/docs/stacked-branches/11_overview.jpg" />
55+
<ImageSection src="/stacked-branches/11_overview.jpg" />
5656

5757
## Workflow
5858

@@ -63,49 +63,49 @@ you can create a new dependent branch within a lane by clicking the `+` button a
6363
6464
1. Creating a new dependent branch forms a stack within the lane.
6565

66-
<ImageSection src="/img/docs/stacked-branches/1_creating_stack.jpg" />
66+
<ImageSection src="/stacked-branches/1_creating_stack.jpg" />
6767

6868
2. New commits land in the top branch of the stack.
6969

70-
<ImageSection src="/img/docs/stacked-branches/2_new_commits.jpg" />
70+
<ImageSection src="/stacked-branches/2_new_commits.jpg" />
7171

7272
3. Pushing is done for the stack as a whole. Note: The Pull Requests will be created in a way where each branch points to its parent - see [Automatic branch deletion](#automatic-branch-deletion)
7373

74-
<ImageSection src="/img/docs/stacked-branches/3_push_all.jpg" />
74+
<ImageSection src="/stacked-branches/3_push_all.jpg" />
7575

7676
4. Pull requests must be created one at a time starting from the bottom of the stack.
7777

78-
<ImageSection src="/img/docs/stacked-branches/4_create_pr.jpg" />
78+
<ImageSection src="/stacked-branches/4_create_pr.jpg" />
7979

8080
5. The PRs will contain a footer with stack information, and as you add more PRs it will keep all up to date.
8181

82-
<ImageSection src="/img/docs/stacked-branches/5_pr_footer.jpg" />
82+
<ImageSection src="/stacked-branches/5_pr_footer.jpg" />
8383

8484
6. You can drag changes into commits to amend them (e.g. incorporating review feedback) as well as move and squash commits.
8585

8686
<ImageSection
87-
src="/img/docs/stacked-branches/6_modify_commits-amend.jpg"
87+
src="/stacked-branches/6_modify_commits-amend.jpg"
8888
subtitle="Amending a commit"
8989
/>
9090
<ImageSection
91-
src="/img/docs/stacked-branches/6_modify_commits-move.jpg"
91+
src="/stacked-branches/6_modify_commits-move.jpg"
9292
subtitle="Moving a commit to a different branch"
9393
/>
9494
<ImageSection
95-
src="/img/docs/stacked-branches/6_modify_commits-squash.jpg"
95+
src="/stacked-branches/6_modify_commits-squash.jpg"
9696
subtitle="Squashing commits"
9797
/>
9898

9999
7. If a change in your stack is independent (e.g. an unrelated bugfix) it can be moved to a different virtual branch (or stack).
100100
This works for both uncommitted changes and existing commits that you may want to relocate.
101101

102-
<ImageSection src="/img/docs/stacked-branches/7_move_to_vb.jpg" />
102+
<ImageSection src="/stacked-branches/7_move_to_vb.jpg" />
103103

104104
8. Review/merge your PRs starting from the bottom up. After a PR/branch from your stack has been merged, it is reflected in the Stack and you should force push to reflect the changes
105105
on the remote as well.
106106

107-
<ImageSection src="/img/docs/stacked-branches/8_merging-1.jpg" />
108-
<ImageSection src="/img/docs/stacked-branches/8_merging-2.jpg" />
107+
<ImageSection src="/stacked-branches/8_merging-1.jpg" />
108+
<ImageSection src="/stacked-branches/8_merging-2.jpg" />
109109

110110
9. When all branches of a stack have been merged, the stack is complete.
111111

@@ -125,15 +125,15 @@ Of course, in pure Git terms, a stacked branch will contain all the changes from
125125
In order to show only the expected Files changed and Commits for PRs in a stack, each PR is created to target the branch below it in the stack.
126126
This is true for all but the bottom branch in the stack, which targets the default branch of the repository as usual.
127127

128-
<ImageSection src="/img/docs/stacked-branches/9_pr_heads.jpg" />
128+
<ImageSection src="/stacked-branches/9_pr_heads.jpg" />
129129

130130
> Every branch in the stack contains the commits from the branches below it.
131131
132132
This of course does not mean that a Pull Request should be merged into its parent.
133133
When the bottom branch is merged on GitHub, **if** the PR branch is deleted,
134134
GitHub will automatically update any PRs that used to target it to target the default branch instead.
135135

136-
<ImageSection src="/img/docs/stacked-branches/10_branch_deletion.jpg" />
136+
<ImageSection src="/stacked-branches/10_branch_deletion.jpg" />
137137

138138
If the newly merged branch from the bottom of the stack is not deleted, the next PR in line will still target it and there is a risk of accidentally merging it into the now out of data branch.
139139
For this reason it is _highly recommended_ to [enable on GitHub](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-the-automatic-deletion-of-branches) the automatic deletion of branches after merging.

content/docs/features/timeline.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Before GitButler does any major action, it records the state of everything (your
1111

1212
<ImageSection
1313
alt="Virtual Branches Example"
14-
src="/img/docs/timeline-01.avif"
14+
src="/timeline-01.png"
1515
/>
1616

1717

@@ -23,14 +23,14 @@ If you hover over any of the entries, you will see a button named "Revert" that
2323

2424
<ImageSection
2525
alt="Virtual Branches Example"
26-
src="/img/docs/timeline-02.png"
26+
src="/timeline-02.png"
2727
/>
2828

2929
## Recovering Content
3030
Occasionally, GitButler will also take snapshots of files that were changed recently, even if they weren't committed. If this, or any other action, sees changes in files, you can see which ones and view the change by clicking on the file name.
3131

3232
<ImageSection
3333
alt="Virtual Branches Example"
34-
src="/img/docs/timeline-03.avif"
34+
src="/timeline-03.png"
3535
/>
3636

content/docs/features/virtual-branches/branch-lanes.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The interface looks something like this:
1414

1515
<ImageSection
1616
alt="Virtual Branches Example"
17-
src="/img/docs/branch-lanes-01.webp"
17+
src="/branch-lanes-01.webp"
1818
subtitle="An example of working on two branches at the same time, while pending upstream changes wait for you to merge them."
1919
/>
2020

@@ -30,7 +30,7 @@ The "Target" is the view of the target branch that you've set. It will show you
3030

3131
<ImageSection
3232
alt="Virtual Branches Example"
33-
src="/img/docs/merge-upstream.png"
33+
src="/merge-upstream.png"
3434
subtitle="A screenshot showcasing the Target view."
3535
/>
3636

@@ -59,7 +59,7 @@ You can inspect any file change by clicking on the file path. GitButler will exp
5959

6060
<ImageSection
6161
alt="Virtual Branches Example"
62-
src="/img/docs/branch-lanes-03.webp"
62+
src="/branch-lanes-03.webp"
6363
subtitle="Inspecting our file change"
6464
/>
6565

content/docs/features/virtual-branches/commits.mdx

+10-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you want AI to use your diff to generate a commit message, you can hit the "G
1818

1919
<ImageSection
2020
alt="Creating Commits Example"
21-
src="/img/docs/commits-01.gif"
21+
src="/commits-01.gif"
2222
/>
2323

2424
## AI Commit Message Settings
@@ -29,14 +29,14 @@ For both OpenAI and Anthropic, you can either use your own API key to directly s
2929

3030
<ImageSection
3131
alt="AI Commit Settings"
32-
src="/img/docs/commits-02.avif"
32+
src="/commits-02.png"
3333
/>
3434

3535
If you use your own key for OpenAI or Anthropic, you can choose which model you would like us to use.
3636

3737
<ImageSection
3838
alt="AI Commit Settings"
39-
src="/img/docs/commits-03.avif"
39+
src="/commits-03.png"
4040
/>
4141

4242
If you don't want to send your diff to another server, you can also use Ollama, which is a local LLM server. With Ollama, you can run nearly any open source large language model ([Llama 3](https://www.ollama.com/library/llama3), [Phi 3](https://www.ollama.com/library/phi3), [Mistral](https://www.ollama.com/library/mistral), [Gemma](https://www.ollama.com/library/gemma), etc) entirely locally.
@@ -45,7 +45,7 @@ With all of these models, you can also customize the prompt if you want somethin
4545

4646
<ImageSection
4747
alt="AI Commit Settings"
48-
src="/img/docs/commits-04.avif"
48+
src="/commits-04.png"
4949
/>
5050

5151
Custom prompts can contain three variables which we will replace with the appropriate values. Those include:
@@ -63,7 +63,7 @@ This will both rewrite that commit to include the new changes and also rebase ev
6363

6464
<ImageSection
6565
alt="Absorbing New Work"
66-
src="/img/docs/commits-05.gif"
66+
src="/commits-05.gif"
6767
/>
6868

6969
## Undoing Commits
@@ -76,7 +76,7 @@ You can easily undo any commit in your stack by expanding the commit and hitting
7676

7777
<ImageSection
7878
alt="Undoing Commits"
79-
src="/img/docs/commits-06.gif"
79+
src="/commits-06.gif"
8080
/>
8181

8282
## Squashing Commits
@@ -85,7 +85,7 @@ Squashing two commits into a single combined commit is also very simple. Just dr
8585

8686
<ImageSection
8787
alt="Squashing Commits"
88-
src="/img/docs/commits-07.gif"
88+
src="/commits-07.gif"
8989
/>
9090

9191
## Splitting Commits
@@ -94,7 +94,7 @@ Splitting commits is slightly more complex. GitButler allows you to create an "e
9494

9595
<ImageSection
9696
alt="Splitting Commits"
97-
src="/img/docs/commits-08.gif"
97+
src="/commits-08.gif"
9898
/>
9999

100100
You can also notice that I easily edit the commit message by just hitting the "edit message" button.
@@ -105,7 +105,7 @@ You can also arbitrarily change the order of your commits by dragging and droppi
105105

106106
<ImageSection
107107
alt="Moving Commits"
108-
src="/img/docs/commits-09.gif"
108+
src="/commits-09.gif"
109109
/>
110110

111111
## Edit Mode
@@ -117,7 +117,7 @@ The screen will go into "Edit mode", indicating that you're in a special state w
117117
<ImageSection
118118
subtitle="Editing a commit"
119119
alt="Editing a commit"
120-
src="/img/docs/conflicts-edit-mode.png"
120+
src="/conflicts-edit-mode.png"
121121
/>
122122

123123
Then you can change whatever you want and when you click "Save and exit", it will amend the commit you were editing and rebase anything on top of it.

content/docs/features/virtual-branches/committer-mark.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you choose to turn it on as a show of support, GitButler will credit itself a
1818

1919
<ImageSection
2020
alt="Committer Mark"
21-
src="/img/docs/committer-01.gif"
21+
src="/committer-01.gif"
2222
subtitle="What a GitButler aided commit looks like on GitHub"
2323
/>
2424

content/docs/features/virtual-branches/integration-branch.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The way that we handle this relatively well is by creating an "integration" comm
1717

1818
<ImageSection
1919
alt="Viewing Remote Branches"
20-
src="/img/docs/integration-01.avif"
20+
src="/integration-01.png"
2121
subtitle="An 'integration' commit example."
2222
/>
2323

content/docs/features/virtual-branches/merging.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ When you go to update from upstream, GitButler will show you all the branches th
1414

1515
<ImageSection
1616
subtitle="One branch has a conflict with the upstream work"
17-
src="/img/docs/conflicts-incoming.png"
17+
src="/conflicts-incoming.png"
1818
alt="Conflicts with commits"
1919
/>
2020

2121
In this case, when you perform the rebase, that branch will then contain "conflicted" commits. They will be marked in the UI as conflicted and you can click on them to get a "resolve conflict" button to start the resolution process.
2222

2323
<ImageSection
2424
subtitle="Resolving a conflict"
25-
src="/img/docs/conflicts-conflicted.png"
25+
src="/conflicts-conflicted.png"
2626
alt="Conflicts with commits"
2727
/>
2828

2929
When you click that, GitButler will remove the other virtual branches and other work from your working directory and check out just this commit with it's conflict markers. It will show you a special "edit mode" screen, where you are directly editing this commit.
3030

3131
<ImageSection
3232
subtitle="Resolving a conflict"
33-
src="/img/docs/conflicts-edit.png"
33+
src="/conflicts-edit.png"
3434
alt="Conflicts with commits"
3535
/>
3636

content/docs/features/virtual-branches/overview.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Virtual branches are just like normal Git branches, except that you can work on
1515

1616
<ImageSection
1717
alt="Virtual Branches Example"
18-
src="/img/docs/virtual-branches-01.jpeg"
18+
src="/virtual-branches-01.jpeg"
1919
subtitle="An example of working on two branches at the same time, while pending upstream changes wait for you to merge them."
2020
/>
2121

@@ -50,18 +50,18 @@ Each time you commit on a virtual branch, GitButler calculates what that branch
5050
## Applying and Unapplying Branches
5151
Since there isn't just a single branch you can be on, you don't "switch" branches, which implies replacement. You simply "apply" branches, which takes whatever changes they represent and adds them to your working directory. If you don't want those changes in your working directory anymore, you can "unapply" them, which removes only those changes.
5252

53-
<ImageSection subtitle="Click 'unapply' for any branch to stash it and remove it's changes from the working directory" src="/img/docs/virtual-branches-02.jpeg" alt="Virtual Branch Apply / Unapply" />
53+
<ImageSection subtitle="Click 'unapply' for any branch to stash it and remove it's changes from the working directory" src="/virtual-branches-02.jpeg" alt="Virtual Branch Apply / Unapply" />
5454

5555
To delete a virtual branch, you simply unapply it, then left click on it and choose "delete".
5656

5757
## Merging Upstream
5858
Eventually you will have work merged into the branch you chose as your target branch, which will need to be reconciled with all your virtual branches to keep them up to date with where they will eventually need to merge to.
5959

60-
<ImageSection subtitle="Click 'Merge into common base' to integrate upstream changes into your virtual branches." src="/img/docs/merge-upstream.png" alt="Branch Commit List" />
60+
<ImageSection subtitle="Click 'Merge into common base' to integrate upstream changes into your virtual branches." src="/merge-upstream.png" alt="Branch Commit List" />
6161

6262
Upstream work will automatically be shown in your sidebar in the "Target" section. When you click "Merge into common base" (or the "Update" button next to your "Workspace" section), we will attempt to integrate that work with your existing virtual branches. Each branch, applied or unapplied, will try to be updated with the new work.
6363

64-
<ImageSection subtitle="Click 'Update workspace' to integrate upstream changes into your virtual branches." src="/img/docs/merge-upstream-incoming.png" alt="Update Workspace" />
64+
<ImageSection subtitle="Click 'Update workspace' to integrate upstream changes into your virtual branches." src="/merge-upstream-incoming.png" alt="Update Workspace" />
6565

6666
For each virtual branch you have, we will show you if the incoming upstream work has conflicts with each branch. If there are conflicts, you can choose to stash the branch or go ahead and rebase with conflicts, which you can fix later.
6767

@@ -72,15 +72,15 @@ If you do rebase work that has conflicts, the commit will be marked as being in
7272

7373
<ImageSection
7474
subtitle="When your commits have conflicts"
75-
src="/img/docs/conflicts-commits.png"
75+
src="/conflicts-commits.png"
7676
alt="Conflicts with commits"
7777
/>
7878

7979
This is different from how you might have dealt with conflicts in Git before. If there is conflicting work in a commit, GitButler will ignore the parts that conflict and keep rebasing. In other words, rebases _always_ work. Then you can focus resolving each conflicted commit, one at a time.
8080

8181
<ImageSection
8282
subtitle="Resolving a conflict"
83-
src="/img/docs/conflicts-resolve.png"
83+
src="/conflicts-resolve.png"
8484
alt="Conflicts with commits"
8585
/>
8686

content/docs/features/virtual-branches/pushing-and-fetching.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can set your preference (and test if it works) in your project's "Git authen
1212

1313
<ImageSection
1414
alt="Git Authentication Settings"
15-
src="/img/docs/pushing.png"
15+
src="/pushing.png"
1616
/>
1717

1818
Once that's done, GitButler will be able to automatically fetch upstream work and push new branches to your upstream server.

0 commit comments

Comments
 (0)