Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active February 23, 2019 23:25
Show Gist options
  • Select an option

  • Save daliborgogic/125130347fe13c3dc20c94e1fd422c36 to your computer and use it in GitHub Desktop.

Select an option

Save daliborgogic/125130347fe13c3dc20c94e1fd422c36 to your computer and use it in GitHub Desktop.
<template>
<button @click="$emit('emit')">
<slot />
<span v-if="cta">{{ cta }}</span>
</button>
</template>
<script>
export default {
props: {
cta: {
type: String,
default: null
}
}
}
</script>
<style lang="postcss" scoped>
button {
--color: 255,255,255;
--background-color: 0,118,255; /*0,118,255*/
/* min-width: 64px; */
height: 32px;
color: rgb(var(--background-color));
background-color: transparent;
border: 1px solid transparent;
border-radius: 4px;
padding: 0 16px;
font-size: 13px;
font-family: inherit;
font-weight: 600;
letter-spacing: .0892857143em;
text-transform: uppercase;
user-select: none;
-webkit-appearance: none;
position: relative;
margin: 8px 0;
will-change: transform, opacity;
outline: none;
line-height: 24px;
}
svg {
margin-top: -2px;
/* margin-right: 8px; */
vertical-align: middle;
}
button::before {
content: '';
background-color: rgb(var(--background-color));
opacity: 0;
pointer-events: none;
}
button::before {
position: absolute;
top: 0;
left: 0;
width: calc(100% + 2px);
height: calc(100% + 2px);
transform: scale(1);
transition: opacity 15ms linear, background-color 15ms linear;
border-radius: 4px;
z-index: 1;
}
[outlined] {
background-color: transparent;
border-color: rgb(var(--background-color));
margin: 8px 16px;
}
button:hover { cursor: pointer; }
button:hover::before { opacity: .05; }
button:active::before { opacity: 0.12; }
/* button:not(:disabled) { background-color: red; } */
[raised],
[unelevated] {
color: rgb(var(--color));
background-color: rgb(var(--background-color));
margin: 8px 16px;
}
[raised] {
box-shadow: rgba(var(--background-color), 0.24) 0px 5px 10px 0px;
transition: box-shadow 150ms ease-in;
}
[raised]:active {
transform: scale(0.98);
box-shadow: none;
}
[unelevated] { box-shadow: none; }
button:disabled { color: #7f7f7f; }
</style>
@daliborgogic
Copy link
Author

daliborgogic commented Feb 23, 2019

    <AppButton cta="Button" />
    <AppButton raised cta="raised" />
    <AppButton outlined>
      <Icon />
    </AppButton>
    <AppButton>
      <Icon />
    </AppButton>
    <AppButton cta="unelevated" unelevated />
    <AppButton cta="outlined" outlined />
    <AppButton cta="disabled" disabled />
    <AppButton cta="outlined" outlined>
      <Icon />
    </AppButton>
    <AppButton cta="emit" @emit="foo" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment