Skip to content

Commit bd64e7e

Browse files
committed
DRY component, fix spelling, use emojis sparingly
1 parent ee189df commit bd64e7e

9 files changed

Lines changed: 87 additions & 82 deletions

File tree

app/javascript/components/localization/glossary-entries/show/Proposed/ProposalActions.tsx

Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -100,36 +100,37 @@ export function ProposalActions({
100100
}
101101
}, [redirectToNext])
102102

103-
return (
104-
<div className="buttons">
105-
<div className="flex gap-8 items-center">
106-
<button
107-
type="button"
108-
className="btn-s btn-default"
109-
onClick={onEditMode}
110-
>
111-
Edit
112-
</button>
113-
{hasBeenEdited && (
114-
<button
115-
type="button"
116-
className="btn-s btn-default"
117-
onClick={onResetChanges}
118-
>
119-
Reset changes
120-
</button>
121-
)}
122-
</div>
103+
const SkipButton = ({
104+
children = 'Skip',
105+
}: {
106+
children?: React.ReactNode
107+
}) => (
108+
<button type="button" className="btn-s btn-default" onClick={handleSkip}>
109+
{children}
110+
</button>
111+
)
112+
113+
const EditButton = () => (
114+
<button type="button" className="btn-s btn-default" onClick={onEditMode}>
115+
Edit translation
116+
</button>
117+
)
118+
119+
const ResetButton = () => (
120+
<button
121+
type="button"
122+
className="btn-s btn-default"
123+
onClick={onResetChanges}
124+
>
125+
Reset changes
126+
</button>
127+
)
123128

124-
{hasBeenEdited ? (
129+
const renderRightActions = () => {
130+
if (hasBeenEdited) {
131+
return (
125132
<div className="flex gap-8 items-center">
126-
<button
127-
type="button"
128-
className="btn-s btn-default"
129-
onClick={() => handleSkip()}
130-
>
131-
Skip
132-
</button>
133+
<SkipButton />
133134
<button
134135
type="button"
135136
className="btn-s btn-primary"
@@ -144,52 +145,56 @@ export function ProposalActions({
144145
Update proposal
145146
</button>
146147
</div>
147-
) : isOwn ? (
148+
)
149+
}
150+
151+
if (isOwn) {
152+
return (
148153
<div className="flex gap-8 items-center">
149-
<button
150-
type="button"
151-
className="btn-s btn-default"
152-
onClick={() => handleSkip()}
153-
>
154-
Skip
155-
</button>
154+
<SkipButton />
156155
<span>(This is your proposal so you cannot approve it)</span>
157156
</div>
158-
) : (
159-
<div className="flex gap-8 items-center">
160-
<button
161-
type="button"
162-
className="btn-s btn-default"
163-
onClick={() => handleSkip()}
164-
>
165-
Skip
166-
</button>
167-
<button
168-
type="button"
169-
className="btn-s btn-default"
170-
onClick={() =>
171-
approveProposal({
172-
translationUuid,
173-
proposalUuid: proposal.uuid,
174-
})
175-
}
176-
>
177-
Approve
178-
</button>
179-
<button
180-
type="button"
181-
className="btn-s btn-default"
182-
onClick={() =>
183-
rejectProposal({
184-
translationUuid,
185-
proposalUuid: proposal.uuid,
186-
})
187-
}
188-
>
189-
Reject
190-
</button>
191-
</div>
192-
)}
157+
)
158+
}
159+
160+
return (
161+
<div className="flex gap-8 items-center">
162+
<SkipButton>Skip this entry</SkipButton>
163+
<button
164+
type="button"
165+
className="btn-s btn-warning"
166+
onClick={() =>
167+
rejectProposal({
168+
translationUuid,
169+
proposalUuid: proposal.uuid,
170+
})
171+
}
172+
>
173+
Reject
174+
</button>
175+
<button
176+
type="button"
177+
className="btn-s btn-primary"
178+
onClick={() =>
179+
approveProposal({
180+
translationUuid,
181+
proposalUuid: proposal.uuid,
182+
})
183+
}
184+
>
185+
👍 Sign Off
186+
</button>
187+
</div>
188+
)
189+
}
190+
191+
return (
192+
<div className="buttons">
193+
<div className="flex gap-8 items-center">
194+
<EditButton />
195+
{hasBeenEdited && <ResetButton />}
196+
</div>
197+
{renderRightActions()}
193198
</div>
194199
)
195200
}

app/javascript/components/localization/glossary-entries/show/Unchecked.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function Unchecked({ translation }: { translation: GlossaryEntry }) {
8080
<div className="body">
8181
<p className="text-16 leading-140 mb-10">
8282
How should we translate this word in the context of Exercism? What is
83-
the most natural equivelent in{' '}
83+
the most natural equivalent in{' '}
8484
{nameForLocale(translation.locale, { displayInEnglish: true })}?
8585
</p>
8686
<div className="flex items-center gap-8 mb-12">
@@ -121,11 +121,11 @@ export function Unchecked({ translation }: { translation: GlossaryEntry }) {
121121
<div className="buttons flex justify-between">
122122
<div className="buttons flex gap-8">
123123
<button onClick={handleEdit} className="btn-s btn-default">
124-
✏️&nbsp;&nbsp;Edit Translation
124+
Edit Translation
125125
</button>
126126
{hasBeenEdited && (
127127
<button onClick={resetChanges} className="btn-s btn-default">
128-
↩️ Reset changes
128+
Reset changes
129129
</button>
130130
)}
131131
</div>
@@ -134,7 +134,7 @@ export function Unchecked({ translation }: { translation: GlossaryEntry }) {
134134
onClick={() => handleSkip()}
135135
className="btn-s btn-default"
136136
>
137-
↪️&nbsp;&nbsp;Skip this entry
137+
Skip this entry
138138
</button>
139139
<button onClick={createProposal} className="btn-s btn-primary">
140140
{hasBeenEdited ? '👍 Submit proposal' : '👍 Mark as Checked'}

bootcamp_content/concepts/javascript/array-iteration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515
// 🌱
1616
```
1717

18-
The equivelent code in JavaScript is very similar.
18+
The equivalent code in JavaScript is very similar.
1919

2020
```javascript
2121
for (const emoji of ["😀", "🚀", "🌱"]) {

bootcamp_content/concepts/javascript/manual-mapping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717
log(doubled) //-> [2,4,6]
1818
```
1919

20-
The equivelent code in JavaScript is very similar.
20+
The equivalent code in JavaScript is very similar.
2121

2222
```javascript
2323
const numbers = [1, 2, 3];

bootcamp_content/projects/javascript-fundamentals/exercises/dna-to-rna/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ Given a DNA strand, its transcribed RNA strand is formed by replacing each nucle
3636
- `A` -> `U`
3737

3838
Create a function called `dnaToRna(dna)`.
39-
It should take a DNA string as it's input, and should return a string representing the RNA equivelent.
39+
It should take a DNA string as it's input, and should return a string representing the RNA equivalent.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Receives a number as its input
2-
// Should return the equivelent raindrop sounds
2+
// Should return the equivalent raindrop sounds
33
export function stormySounds(number) {}

bootcamp_content/projects/number-puzzles/exercises/raindrops/example.jiki

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Receives a number as its input
2-
// Should return the equivelent raindrop sounds
2+
// Should return the equivalent raindrop sounds
33
function raindrops with number do
44
set result to ""
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Receives a number as its input
2-
// Should return the equivelent raindrop sounds
2+
// Should return the equivalent raindrop sounds
33
function raindrops with number do
44

55
end

bootcamp_content/projects/string-puzzles/exercises/rna-transcription/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Given a DNA strand, its transcribed RNA strand is formed by replacing each nucle
3434
- `A` -> `U`
3535

3636
Create a function called `dna_to_rna(dna)`.
37-
It should take a DNA string as it's input, and should return a string representing the RNA equivelent.
37+
It should take a DNA string as it's input, and should return a string representing the RNA equivalent.
3838

3939
### Functions
4040

0 commit comments

Comments
 (0)