@namelivia/vue-components 4.2.1 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namelivia/vue-components",
3
- "version": "4.2.1",
3
+ "version": "4.3.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "scripts": {
@@ -2,13 +2,37 @@ import RegularButton from './RegularButton.vue'
2
2
 
3
3
  describe('<RegularButton />', () => {
4
4
 
5
- it('should properly render', () => {
5
+ it('should display text', () => {
6
6
  cy.mount(RegularButton, {
7
7
  props: {
8
8
  text: 'Click me'
9
9
  }
10
10
  })
11
+ cy.get('button').should('contain.text', 'Click me')
12
+ })
13
+
14
+ it('clicking the button fires a click event', () => {
15
+ const onClickSpy = cy.spy().as('onClickSpy')
16
+ cy.mount(RegularButton, {
17
+ props: { text: 'Click me', onClick: onClickSpy }
18
+ })
19
+ cy.get('button').click()
20
+ cy.get('@onClickSpy').should('have.been.called')
21
+ })
22
+
23
+ it('when the button is loading, should show the loading text and be disabled', () => {
24
+ const onClickSpy = cy.spy().as('onClickSpy')
25
+ cy.mount(RegularButton, {
26
+ props: {
27
+ text: 'Click me',
28
+ loading: true,
29
+ textWhileLoading: 'Loading...',
30
+ onClick: onClickSpy
31
+ }
32
+ })
33
+ cy.get('button').should('not.contain.text', 'Click me')
34
+ cy.get('button').should('contain.text', 'Loading...')
35
+ cy.get('button').should('be.disabled')
11
36
  })
12
- //TODO: Add more tests
13
37
 
14
38
  })
@@ -1,6 +1,6 @@
1
1
  <template lang="pug">
2
- button(v-on:click="onClick" class="regular-button")
3
- | {{text}}
2
+ button(v-on:click="onClick" :class="cssClass" :disabled="loading")
3
+ | {{ loading ? textWhileLoading : text }}
4
4
  </template>
5
5
 
6
6
  <script lang="js">
@@ -9,8 +9,24 @@ export default defineComponent({
9
9
  name: "RegularButton",
10
10
  props: {
11
11
  text: String,
12
+ loading: {
13
+ type: Boolean,
14
+ default: false,
15
+ },
16
+ textWhileLoading: {
17
+ type: String,
18
+ default: '...',
19
+ },
12
20
  },
13
21
  emits: ['click'],
22
+ computed: {
23
+ cssClass: function () {
24
+ if (this.loading) {
25
+ return 'regular-button loading';
26
+ }
27
+ return 'regular-button'
28
+ },
29
+ },
14
30
  methods: {
15
31
  onClick(evt) {
16
32
  this.$emit('click', evt);
@@ -34,5 +50,14 @@ export default defineComponent({
34
50
  .regular-button:hover {
35
51
  background-color: var(--color-regular-hover);
36
52
  }
53
+
54
+ /* Loading state */
55
+ .loading {
56
+ background-color: var(--color-regular-disabled);
57
+ cursor: wait;
58
+ }
59
+ .loading:hover {
60
+ background-color: var(--color-regular-disabled);
61
+ }
37
62
  </style>
38
63
 
@@ -45,23 +45,13 @@ export default defineComponent({
45
45
  justify-content: center;
46
46
  padding: 0.5rem;
47
47
  border-radius: var(--border-radius-big);
48
- color: var(--color-menu-button);
48
+ color: var(--color-navbar-text);
49
49
  background-color: transparent;
50
50
  transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out;
51
51
  border: none;
52
52
  cursor: pointer;
53
53
  }
54
54
 
55
- .menu-button:hover {
56
- color: var(--color-menu-button-text-hover);
57
- background-color: var(--color-menu-button-hover);
58
- }
59
-
60
- .menu-button:focus {
61
- outline: none;
62
- box-shadow: 0 0 0 3px var(--color-menu-button-shadow-focus);
63
- }
64
-
65
55
  .menu-icon {
66
56
  display: block;
67
57
  height: 1.5rem;
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- a(:href="href" :class="linkClass" aria-current="page")
2
+ a(:href="linkDestination" :class="linkClass" aria-current="page")
3
3
  | {{ text }}
4
4
  </template>
5
5
  <script lang="js">
@@ -24,34 +24,37 @@ export default defineComponent({
24
24
  }
25
25
  return 'regular-link'
26
26
  },
27
+ linkDestination: function () {
28
+ return this.current ? '#' : this.href
29
+ },
27
30
  },
28
31
  })
29
32
  </script>
30
33
  <style scoped>
31
34
  .current-link {
32
- background-color: #111827;
33
- color: #ffffff;
35
+ background-color: var(--color-navbar-current-background);
36
+ color: var(--color-navbar-text);
34
37
  display: block;
35
38
  padding-left: 0.75rem;
36
39
  padding-right: 0.75rem;
37
40
  padding-top: 0.5rem;
38
41
  padding-bottom: 0.5rem;
39
42
  border-radius: 0.375rem;
40
- font-size: 1rem;
41
- font-weight: 500;
43
+ font-size: var(--font-size-navbar);
44
+ text-decoration: none;
45
+ cursor: default;
42
46
  }
43
47
  .regular-link {
44
- color: #d1d5db;
48
+ color: var(--color-navbar-text);
45
49
  display: block;
46
50
  padding: 0.5rem 0.75rem;
47
51
  border-radius: 0.375rem;
48
- font-size: 1rem;
49
- font-weight: 500;
52
+ font-size: var(--font-size-navbar);
50
53
  transition: background-color 0.2s ease, color 0.2s ease;
54
+ text-decoration: none;
51
55
  }
52
56
 
53
57
  .regular-link:hover {
54
- background-color: #374151;
55
- color: #ffffff;
58
+ background-color: var(--color-navbar-link-background);
56
59
  }
57
60
  </style>
@@ -14,6 +14,7 @@ transition(
14
14
  :key="link.id"
15
15
  :href="link.href"
16
16
  :text="link.text"
17
+ :current="link.current"
17
18
  )
18
19
  </template>
19
20
  <script lang="js">
@@ -64,7 +65,7 @@ export default defineComponent({
64
65
  display: flex;
65
66
  flex-direction: column;
66
67
  gap: 0.25rem;
67
- background-color: #1f2937;
68
+ background-color: var(--color-navbar-background);
68
69
  }
69
70
  @media (min-width: 640px) {
70
71
  #mobile-menu {
@@ -8,9 +8,9 @@ export default {
8
8
  export const Default = {
9
9
  args: {
10
10
  links: [
11
- { text: 'Home', href: '/' },
12
- { text: 'About', href: '/about' },
13
- { text: 'Contact', href: '/contact' },
11
+ { text: 'Home', href: '/home', current: true },
12
+ { text: 'About', href: '/about', current: false },
13
+ { text: 'Contact', href: '/contact', current: false },
14
14
  ],
15
15
  locale: 'en',
16
16
  currentUserEmail: 'foo@bar.com',
@@ -74,6 +74,7 @@ export default defineComponent({
74
74
  </script>
75
75
  <style scoped>
76
76
  .navbar {
77
+ background-color: var(--color-navbar-background);
77
78
  }
78
79
 
79
80
  .navbar-container {
@@ -82,7 +83,6 @@ export default defineComponent({
82
83
  margin-right: auto;
83
84
  padding-left: 0.5rem;
84
85
  padding-right: 0.5rem;
85
- background-color: #1f2937;
86
86
  }
87
87
 
88
88
  .flex-header {
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- a(:href="href" :class="linkClass" aria-current="page")
2
+ a(:href="linkDestination" :class="linkClass" aria-current="page")
3
3
  | {{ text }}
4
4
  </template>
5
5
  <script lang="js">
@@ -24,35 +24,39 @@ export default defineComponent({
24
24
  }
25
25
  return 'regular-link'
26
26
  },
27
+ linkDestination: function () {
28
+ return this.current ? '#' : this.href
29
+ },
27
30
  },
28
31
  })
29
32
  </script>
30
33
  <style scoped>
31
34
  .current-link {
32
- background-color: #111827;
33
- color: #ffffff;
35
+ background-color: var(--color-navbar-current-background);
36
+ color: var(--color-navbar-text);
34
37
  padding-left: 0.75rem;
35
38
  padding-right: 0.75rem;
36
39
  padding-top: 0.5rem;
37
40
  padding-bottom: 0.5rem;
38
41
  border-radius: 0.375rem;
39
- font-size: 0.875rem;
42
+ font-size: var(--font-size-navbar);
43
+ text-decoration: none;
44
+ cursor: default;
40
45
  }
41
46
 
42
47
  .regular-link {
43
- color: #d1d5db;
48
+ color: var(--color-navbar-text);
44
49
  padding-left: 0.75rem;
45
50
  padding-right: 0.75rem;
46
51
  padding-top: 0.5rem;
47
52
  padding-bottom: 0.5rem;
48
53
  border-radius: 0.375rem;
49
- font-size: 0.875rem;
50
- font-weight: 500;
54
+ font-size: var(--font-size-navbar);
51
55
  transition: background-color 0.2s ease, color 0.2s ease;
56
+ text-decoration: none;
52
57
  }
53
58
 
54
59
  .regular-link:hover {
55
- background-color: #374151;
56
- color: #ffffff;
60
+ background-color: var(--color-navbar-link-background);
57
61
  }
58
62
  </style>
@@ -6,6 +6,7 @@ div(class="links-container")
6
6
  :key="link.id"
7
7
  :href="link.href"
8
8
  :text="link.text"
9
+ :current="link.current"
9
10
  )
10
11
  </template>
11
12
  <script lang="js">
@@ -42,12 +42,15 @@ export default defineComponent({
42
42
  display: flex;
43
43
  align-items: center;
44
44
  padding-right: 0.5rem;
45
+ color: var(--color-navbar-text);
46
+ font-size: var(--font-size-navbar);
45
47
  }
46
48
 
47
49
  .circle-image {
48
50
  border-radius: 9999px;
49
51
  padding: 0.25rem;
50
52
  height: 50px;
53
+ width: 50px;
51
54
  }
52
55
 
53
56
  @media (min-width: 640px) {
package/styles/index.css CHANGED
@@ -24,6 +24,7 @@
24
24
  --color-regular: hsl(210, 100%, 53%);
25
25
  --color-regular-text: hsl(0, 0%, 100%);
26
26
  --color-regular-hover: hsl(210, 100%, 46%);
27
+ --color-regular-disabled: hsl(210, 91%, 70%);
27
28
  /* SELECTOR */
28
29
  --color-selector-label: hsl(210, 4%, 39%);
29
30
  --color-selector-text: hsl(210, 4%, 39%);
@@ -102,4 +103,24 @@
102
103
  /* CONTAINER */
103
104
  --container-max-width: 1200px;
104
105
  --container-marging: 0 auto;
106
+ /* NAVBAR */
107
+ --color-navbar-background: hsl(210, 7%, 21%);
108
+ --color-navbar-text: hsl(0, 0%, 100%);
109
+ --color-navbar-current-background: hsl(210, 80%, 23%);
110
+ --color-navbar-link-background: hsl(210, 50%, 23%);
111
+ --font-size-navbar: 0.875rem;
112
+ }
113
+
114
+ .one-theme{
115
+ /* Danger */
116
+ --color-danger: hsl(43, 84%, 58%);
117
+ --color-danger-text: hsl(0, 0%, 100%);
118
+ --color-danger-hover: hsl(43, 84%, 39%);
119
+ }
120
+
121
+ .another-theme{
122
+ /* Danger */
123
+ --color-danger: hsl(102, 84%, 58%);
124
+ --color-danger-text: hsl(0, 0%, 100%);
125
+ --color-danger-hover: hsl(102, 84%, 39%);
105
126
  }