Skip to content

Vue2 add bounce, shake, and some tests #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 7, 2022
Merged

Vue2 add bounce, shake, and some tests #364

merged 13 commits into from
Jun 7, 2022

Conversation

jasonlundien
Copy link
Member

@jasonlundien jasonlundien commented Apr 25, 2022

PR adds bounce, shake, beat-fade and tests in vue-fontawesome 2.x.
Also updates the deps (thank you @ej2)!

@@ -37,7 +37,7 @@ if(coreHasFeature(ICON_ALIASES)) {
const vm = mountFromProps({ icon: ['fas', 'close'] })

expect(vm.$el.tagName).toBe('svg')
expect(vm.$el.classList.contains('fa-close')).toBeTruthy()
expect(vm.$el.classList.contains('fa-xmark')).toBeTruthy()
Copy link
Member Author

@jasonlundien jasonlundien Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix failing test here. xmark is the icon name, close is the alias.

@jasonlundien jasonlundien requested a review from ej2 April 26, 2022 19:03
@jasonlundien jasonlundien requested a review from robmadole April 26, 2022 22:07
@jasonlundien jasonlundien marked this pull request as draft April 27, 2022 14:12
@jasonlundien jasonlundien marked this pull request as ready for review April 27, 2022 14:15
Copy link
Member

@ej2 ej2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great! I think @robmadole should review before we merge.

@jasonlundien jasonlundien changed the title add bounce, shake, and some tests Vue2 add bounce, shake, and some tests May 4, 2022
DEVELOPMENT.md Outdated
@@ -16,8 +16,8 @@ test | Execute unit tests
1. Update `package.json` and change `version`
1. Update `README.md` and `package.json`; adding any contributors
1. Update the `CHANGELOG.md`
1. `npm publish`
1. `npm publish --registry https://npm.fontawesome.com`
1. `npm publish --tag 2x`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonlundien I've looked at a few projects and there doesn't seem to be a solid convention for how you tag major versions.

So let's do it like this:

  • If it's compatible with Vue 2: latest-2
  • For Vue 3: latest-3

package.json Outdated
"test.latest": "npm --no-save install @fortawesome/fontawesome-svg-core@latest @fortawesome/free-solid-svg-icons@latest && jest --silent",
"test.next": "npm --no-save install @fortawesome/fontawesome-svg-core@next @fortawesome/free-solid-svg-icons@next && jest --silent",
"test.next.proregistry": "npm --userconfig .npmrc.proregistry --registry https://npm.fontawesome.com install --no-save @fortawesome/fontawesome-svg-core@next @fortawesome/free-solid-svg-icons@next && jest --silent",
"test": "npm --no-save install @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons && jest --silent",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonlundien @ej2 can we update the tests so that it works like our React component?

https://github.com/FortAwesome/react-fontawesome/blob/master/package.json#L38-L40

The reason for both of them is so that we can test with the FA 5 and 6 versions.

type: String,
default: null,
validator: (value) => ['horizontal', 'vertical', 'both'].indexOf(value) > -1
type: [Boolean, String],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you did there...that's clever. Nice.

This seems rather tricky now. Have we documented how this works?

Copy link
Member Author

@jasonlundien jasonlundien May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is interesting about flip is that we use flip as a standalone animation that actually continuously flips the icon over and over. Ex: <i class="fa-solid fa-compact-disc fa-flip"></i>

And we also use flip to rotate icons (not an animation it just rotates the icon, not continuously). Ex. <i class="fa-solid fa-snowboarding fa-flip-vertical"></i>

We do have both documented:
Rotate: https://fontawesome.com/docs/web/style/rotate#rotate-classes
Animation: https://fontawesome.com/docs/web/style/animate#flip

The flip animation was NOT working with our Vue 2 or Vue 3 packages... this fixes it.

test('horizontal', () => {
const vm = mountFromProps({ icon: faCoffee, flip: "horizontal" })

expect(vm.$el.classList.contains('fa-flip-horizontal')).toBeTruthy()
expect(vm.$el.classList.contains('fa-flip-vertical')).toBeFalsy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you add expect(vm.$el.classList.contains('fa-flip')).toBeFalsy() you will get a surprising test failure...I will comment down below as to why I think this.

src/utils.js Outdated
@@ -15,12 +15,16 @@ export function classList (props) {
'fa-border': props.border,
'fa-li': props.listItem,
'fa-inverse': props.inverse,
'fa-flip': props.flip,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to be

Suggested change
'fa-flip': props.flip,
'fa-flip': props.flip === true,

Otherwise since a string is truthy I think anytime the value is horizontal or vertical or both you'll get the fa-flip class applied.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were/are right about the failing test @robmadole without having this... I actually saw my icons continuously rotating and ignored it for whatever reason. This addition, however, does prevent the icons from flipping yet allowing them to have been "rotated" as desired.

@jasonlundien jasonlundien requested a review from robmadole May 19, 2022 20:52
@jasonlundien jasonlundien merged commit 8b5d2ca into 2.x Jun 7, 2022
@jasonlundien jasonlundien deleted the bounce-shake-test branch June 7, 2022 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants