Hello everyone! I wanted to share how I tackled a technical test for a
job application: a reusable <MyButton> in Vue 3 and
TypeScript.
I’ll be honest: at first I sat there staring at a point in space.
Enable, disable, change the color. It looked too simple, and that felt
strange. I thought maybe I was missing something. So I decided not to
take it lightly.
My thesis was this: build a quality component by extending the APIs
Vue already gives you. I did not want to overcomplicate the button that
already exists in HTML. A regular HTML button already has properties,
events, keyboard behavior. It is already accessible. It is already
battle-tested.
The brief was small. Vue 3, TypeScript, enable and disable, change
color, extras welcome. I think what they wanted to see was how I use
TypeScript, accessibility, UX, tests, and how I work with AI — not a
circus of variants.
I could have done many things: animations, thousands of colors, a
Storybook. The reality is that we developers often build things nobody
asked for. I wanted to keep it simple.
The button looks small. What I want to show is the process: spec-driven
development with AI. Specs first. Then the agents. I did not paste the
brief into a model and send whatever it generated.
Improve, don’t replace
Everything a developer already knows about
<button> has to keep working. Focus, keyboard,
disabled, type, form, aria-*,
@click. My own API sits on top:
variant, size, loading, and an
#icon slot.
The less we overwrite native behavior, the less probability we have of
shipping a bug. That is why the root is a real
<button>, not a
<div role="button">.
Spec-driven development, with AI
I’ll be honest: I used AI to help me approach the problem.
Cursor is my editor right now. I wanted a clear perspective before
installing anything.
The method has a name I like: spec-driven development, SDD. Specs
first. Then implement. The spec is not a forty-page document. It is
the thesis, and the things that cannot move: a real HTML
<button>, no custom click emit, loading is state
not a spinner, TypeScript extends what Vue already typed.
I wrote the requirements as a template for the agents. Then I went in
stages. One agent implements against the spec. Another agent, with a
different context, reviews the diff. Then fixes. Then tests. Then a
pass for UX and accessibility. I do not let the same chat do all of
it. Fresh context is the point. The first agent is proud of the
spinner it invented. The second one can see that the spinner breaks
the thesis.
What I keep checking is that the AI does not break the thesis. A built-in spinner or a custom click emit looks helpful. It is not. I also commit in small steps, so if I hit a bug I can isolate it. And I still open the browser myself. Specs do not replace that.
How I structured the component
Let me show you a bit of the code. No big dependencies: Vue,
TypeScript, Vite, Vitest. One folder per component.
MyButton.types.ts is the contract,
MyButton.vue is the native button,
MyButton.test.ts is what cannot break.
App.vue is not the component. I used it as a living
catalog, with a few SVG icons — an arrow, a trash can, a bookmark —
so you can see every capability without reading the source first.
Vue 3 already forwards undeclared attrs and native listeners to that
single root. I did not proxy $attrs by hand.
TypeScript: extend the native API, don’t swallow it
I imported ButtonHTMLAttributes from Vue and extended
that. I did not copy the HTML catalog by hand. On top I added what I
thought was enough: three sizes, an icon slot left or right, four
colors. Primary is a pretty standard blue.
There is a trap. If you do
defineProps<ButtonHTMLAttributes & …>(), Vue
treats onClick as a prop, and @click stops
being a native listener. So I split the types. I also did not
defineEmits(['click']): a custom emit can fire
even when the native button is disabled.
MyButtonProps goes to defineProps.
MyButtonPublicProps is the conceptual contract — including
id, aria-*, @click. I do not
pass that one to defineProps. In the template the thesis
has to be visible:
Loading is a state, not a spinner
loading disables the native button, sets
aria-busy, and leaves the text on the button. A screen
reader still has a name — "Guardar" — not an anonymous
glyph. The drawing lives in #icon="{ loading }".
If I baked one spinner into MyButton, I would couple the component to
one idea of loading.
In the catalog I have a Save button I like a lot. It simulates a call
with setTimeout. Native @click. No custom
event.
Why the default type is "button"
This is the only place where I lie to HTML on purpose. In HTML, a
<button> without type is
submit. In a reusable component that is a trap: Cancel
inside a form would send the form.
So MyButton defaults to type="button". Enviar
asks for type="submit". Cancelar does not
declare type, and the form does not send. You can try it
in the live playground:
btn-arq-challenge.vercel.app.
Tests, and testing it myself in the browser
There are 27 tests. They cover the contract, not the paint: the root
is a <button>, loading disables for
real, variant does not leak as an HTML attribute, the
default type does not submit a form.
Vue Test Utils trigger('click') on a disabled
button, in jsdom, still fires. In the browser it does not. So when
the real block matters, I use element.click().
I also tested it in the browser myself: Enviar and Cancelar, mouse
and keyboard. Accessibility is not a badge. Native controls already
work with keyboards, screen readers, people who confuse colors, people
who cannot see the screen. Overwriting that is how you ship bugs.
Maybe a full a11y pass was a bit outside the scope. I still did not
want to skip it: :focus-visible,
prefers-reduced-motion, aria-busy only when
loading is true.
The extra: a module you can install
The brief also asked to share the component with other developers. I
did not want to overcomplicate the main solution, so I put this extra
on another branch: feat/library-package. Same source, two
outputs: the playground in dist-app/, and an ESM module
in dist/. Vue is a peer dependency. CSS is a separate
import. Types are flattened into one index.d.ts so a
consumer declare module '*.vue' does not
clobber the props. private: true so I do not publish by
accident.
import { MyButton } from 'btn-arq-challenge'
import 'btn-arq-challenge/style.css'
If you skip the CSS, the button still works. It just has no styles.
For the test, npm pack was enough to prove the extra. I
could have added Storybook, tokens, infinite variants. The requirement
was a reusable button, not a design system. Keep it simple.
Takeaways
Improve the native control. Do not replace it. Specs first. Then the
agents. Then I still test it in the browser. TypeScript should
extend what Vue already typed. Loading is state. Events are the DOM
events. Tests should match the browser.
The library lives on
feat/library-package
until I merge it to main. The playground is
here.
I had a good time with this one, even if it started looking too easy.
I’m always open to feedback. If you’re a recruiter or a
potential client looking for a developer with experience in Vue,
TypeScript, and this kind of AI-assisted component work, let’s
connect.
