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
[WIP] V5 #499
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's so much stuff to go through, although I haven't found anything standing out at first glance. Great job 💪
I released |
All the imports and types files seem to work properly (esp. with the |
One last thing about the API that has annoyed me is the whole Current and inconsistent tippy.defaults;
tippy.setDefaults(Options);
instance.props;
instance.set(Options); Consistent, but Options represents “optional” right? Not the merged interface with the defaults… that was my original problem with this. The options they pass in aren't the same as tippy.defaultOptions;
tippy.setDefaultOptions(Options);
instance.setOptions(Options);
instance.options; Consistent, dropping “Options” completely in favour of props, never mentioning Options. tippy.defaultProps;
tippy.setDefaultProps(Partial<Props>);
instance.setProps(Partial<Props>);
instance.props; Need your help with this @KubaJastrz 🤣 |
I'm not sure where I like the terminology of component-based pattern, where you have instances of a component and different properties you can use them with ( I was really confused when we were making the first typings earlier 😛 It's good to make it more consistent finally. Edit: I'm not sure if this made any sense, but |
Really nice explanation. I think you're right here! |
I think we're getting close here... I'll release another alpha soon |
Released Remaining things to do:
I'm planning a June 8-9 final release, next weekend This should be the last major in a while, definitely no more this year anyway (unless Popper.js 2 arrives soon). The next one will be with Popper.js 2 if it ever arrives, or possibly a custom positioning engine or fork of Popper.js... who knows if that will happen in the future 😅 |
Why am I on your todo list 😂 |
From what I could test, IE11 renders things fine visually. Same with the other rendering engines, Safari, Firefox, iOS Safari. IE11 did bug on the FLIP demo sometimes, but that's related to my current buggy WIP implementation of it and not this actual V5 core code. |
I'm still not sure about the v4import 'tippy.js/themes/light.css';
tippy('button', {
theme: 'light'
}); Current PRimport 'tippy.js/themes/light.css';
tippy('button', {
theme: 'tippy-light'
}); ConsistentNeed to consider the Themes use import 'tippy.js/themes/tippy-light.css';
tippy('button', {
theme: 'tippy-light'
}); Just revert to v4's lack of prefix?Haven't heard of CSS style inheriting complaints with themes at all (mainly just global styles). |
This whole
Poluting the global styles is not a very good idea despite lack of complaints 😛 @mreinstein, what your thoughs on that? |
Our CSS isn't polluting because it's prefixed with the Maybe a good compromise: Use v4's lack of prefix, but the default |
Thanks for reaching out! To be honest I'm not sure I understand what is being suggested in the above PR comment. I can tell you what my use case is: I'm including tippy as a 3rd party module in my code bundle that gets embedded on some very large retail websites, and they have particular demands about not polluting their web page globals with styles and/or javascript. Here is what my build process looks like when I'm including tippy in distributed code: git clone git@github.com:atomiks/tippyjs.git
cd tippyjs
npm install
NAMESPACE=acmecorp npm run build
cp umd/index.all.min.js ~/Sites/acmecorp/scripts/lib/tippy/index.all.min.js Then I copy the contents of This means that all tippy related css starts with |
So just to make things clear: The CSS is like this for every selector: .tippy-iOS {}
.tippy-popper {}
.tippy-tooltip.light-theme {} I consider it non-polluting because it has the library's name as a prefix, which is its own namespace unless the website is using Where I did see a problem is if the user had And also, I've always relied on attributes like [data-state='visible'] {
/* breaking tippy here */
} Which is why I didn't use Regarding the "3rd party module" thing: It would be nice if you could change the prefix at runtime instead of build-time. The CSS files are the main problem. For the main CSS - only thing I can think of is doing something to the bundled file to make all of the const css = "...";
let namespacePrefix = 'tippy';
function injectCSS(css) {/*...*/}
setTimeout(() => {
injectCSS(css.replace(/tippy/g, namespacePrefix);
});
// ...
tippy.setNamespacePrefix = str => {
namespacePrefix = str;
});
|
I actually think it's superior having it done at build time. I have no need to dynamically change this, and having less javascript and other crap around at run time is all the better. Many of the websites that host these 3rd party widgets have piles upon piles of 3rd party junk running. Anything I can do to make it more static and cut down on the amount of unnecessary dynamism helps make the experience better. |
one thing that would be super nice (and if this is difficult it's not that big of a deal) but I'd love to be able to have another environment variable I could pass in at the build step, which changes the default bundled theme. e.g., if I wanted to bundle NAMESPACE=acmecorp THEME=material npm run build I know we talked about this in #484 and it was not trivial, but maybe now that you're already in there doing a major version bump this isn't that crazy of a change? :-) |
I don't think that is too hard to do My guess is something like this function createPluginSCSS(output) {
const theme = process.env.THEME
const data =
`$namespace-prefix: ${NAMESPACE_PREFIX};` +
(theme ? `@import './themes/${theme}.scss';` : '')
return sass({
output,
options: { data },
processor(css) {
return postcss([autoprefixer, cssnano])
.process(css, { from: undefined })
.then(result => result.css)
},
})
} |
So it was really easy 😆 |
@KubaJastrz |
Thinking of replacing |
Sorry for the delays but I'm having a pretty busy week. I even missed your ping 😅 |
It's okay there's no rush anyway
Just glaring flaws/mistakes that seeped through. It might be difficult to understrand the nuances of various things without rigorously playing around with it yourself Full list of development demos (I'm going to add a npm run dev # Single reference element button, use to develop new features
npm run dev:themes # Develop new themes, ensure existing themes are working
npm run dev:animations # Develop new animations, ensure existing animations are working
npm run dev:flip # The holy grail of dimensions transitions
npm run dev:addons # delegate + createSingleton, for now
npm run dev:ui # Common UI patterns: nested hover menus, tooltip+popover on single element combo, combobox, dropdowns, etc. I did attempt to make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Code looks much simpler now, especially rollup config.
I've noticed that there are copied tippy bundles in the website
directory, maybe you could use bundles from root dir?
I think my concern with that was you need to not have the directory cleaned. But |
Well, maybe we could copy the bundles into website dir but have it gitignored? And just add command to rebuild tippy to website readme |
Causes conflicts
Remove unnecessary properties, always use px units
Let's finally merge & release.. 😳 |
Tippy v5
The main goal of this version is to:
Highlights
touch: ["hold", delay]
prop (for long press behavior)arrow: string | Element
values to use your own shapecreateSingleton
method, supersedesgroup()
Development and production versions of Tippy.js
We're now adding helpful development warnings without bloating bundle size. Development files are
.js
, while production versions are.min.js
.Main filename was renamed from
index.all
totippy.bundle
for better DevTools display.Where's the
umd
folder? The browser format is nowiife
. Node is covered bycjs
, andamd
is dead and/or didn't work withpopper.js
/tippy.js
anyway before because of the.js
suffix apparently (which is whatumd
covered). Now it's not necessary.iife
development version includes the block without the Node-onlyprocess
variable. In the.min
version, it's stripped out entirely (like the other formats).Drop Android 4.4 support
Remove all
-webkit-
prefixed transforms to save 200 minzipped bytes or so.Force
data-placement
anddata-out-of-boundaries
attributesThe inconsistency between
data-animation
andx-placement
has been annoying. Since4.2.0
, we've moved these attributes to the.tippy-tooltip
node, so we can rename them.Default is now
arrow: true
andanimation: 'fade'
Having
animateFill: true
andanimation: 'shift-away'
animation as defaults add a lot of CSS bloat. By making the "bootstrap" tooltip default a lot of code is stripped away.Further reasons listed here: #499 (comment)
If using a custom SVG arrow, import the SVG arrow CSS
Again, for treeshaking reasons, not everyone cares about SVG arrows, so will need to import the CSS separately:
Delays are always 0 in touch and keyboard contexts
I don't see a reason to keep delay here, it's poor UX. If people require this to be configured then we can add it later.
Remove
target
option andtippy.group()
from coreThey've been moved into a file called "addons" to conserve core's size.
createSingleton
has replacedgroup
since its behavior is better and allows transitions since a single tippy is being used.Functions in this bundled file should be treeshaken by bundlers.
Move
followCursor
toplugins
Like the "addons", props are being moved to separate parts because not everyone needs this behavior.
Animations
A ton of work has been gone into considering animations more deeply.
This includes:
animate.css
)animejs
)react-flip-toolkit/core
)Default CSS animations:
shift-toward
,scale
,perspective
animations removedOnly
fade
will remain intippy.css
.Extra CSS animations will be moved to a folder called
animations/
(likethemes/
); there are now 3 variants of each animation expect for fade (subtle
andextreme
added).Example import:
CSS animations (instead of transitions - e.g. animate.css)
We're now using use
top/left/right/bottom: 10px
as the base distance offset, rather than specifying it in the transform. Makes it more compatible with external animation CSS, FLIP libraries, and removes need for thenotransition
technique.There's no need to think about
distance
anymore now due to this.Dimensions transition
See
demo/flip
Remaining problems:
clip-path
based on the placement needed to prevent content overflowing when the tippy has an arrow (since it can't haveoverflow: hidden
)..setProps()
method.Themes
google
theme was renamed tomaterial
, to remove the association with Google..tippy-tooltip[data-animatefill] .tippy-backdrop
selector (to make background-color transparent)New lifecycle functions
onCreate
onUntrigger
onPropsUpdated
onDestroy
Virtual reference elements
Plain objects are not supported anymore - instead, you just pass a placeholder element like this:
This conserves size since we don't need to polyfill element methods in the plain object.
Auto built
index.d.ts
Internal types don't live in
types.ts
so nowindex.d.ts
gets generated on build, which is just a copy ofsrc/types.ts
.Naming
The term "options" is being completely ditched in favor of "props" everywhere. And now consistent methods:
instance.set()
was renamed toinstance.setProps()
tippy.defaults
was renamed totippy.defaultProps
tippy.setDefaults()
was renamed totippy.setDefaultProps()
This directly aligns with the React component model since every prop is dynamic and updateable. Options are now Partial, or termed "optional props". The merged interface is Props as it was before.
showOnInit
->showOnCreate
to match lifecycle hookNew static property
tippy.currentInput
is a mutable object with a single propertyisTouch
. This moves the internalisUsingTouch
flag to this object so that users can access it, as it's sometimes useful in rare cases.i.e.
tippy.currentInput.isTouch
New accessibility defaults for interactive tippys
By default if
interactive: true
, then:{aria: null, appendTo: "parent"}
There's also a warning in DEV if the tippy is not directly after the ref/triggerTarget node. If the user specifies a different appendTo, then it gets ignored as it assumes there are clipping issues and they need a custom focus management solution to handle it.
aria-expanded
attribute also addedaria-describedby
handles multiple tippysTODO
5.1.0 goals:
Current experimental React wrapper