Code Monkey home page Code Monkey logo

Comments (25)

toddanglin avatar toddanglin commented on May 10, 2024 7

Thanks, Nathan.

Is there a pseudo selector for the disabled state on buttons yet? If not, that would be really valuable here, too. For example, when isEnabled=false on a button, this should match:

.myButton:disabled {
   ...
}

from nativescript.

jpdail01 avatar jpdail01 commented on May 10, 2024 3

+1

This would be great. I'd also like to see nth-child pseudo class so we can easily style alternating row color on a listivew:

myListViewItem:nth-child(odd) {
background-color: #ff0000;
}

from nativescript.

codejtech avatar codejtech commented on May 10, 2024 3

would be great to have support for :before and :after as well.

from nativescript.

burkeholland avatar burkeholland commented on May 10, 2024 2

For the segmented bar, it would be ideal if it was possible to style the selected background color via css pseudo selectors. In the case of the segmented bar, only the background color can be changed, but that would at least allow all of the styling to be done in the CSS.

.segmented-bar:selected {
    background-color: #efefef;
}

from nativescript.

BenKingBBC avatar BenKingBBC commented on May 10, 2024 1

Agreed @burkeholland, although in the segmented-bar case I would argue naming it active over selected would be better for aligning with the web equivalent.

from nativescript.

toddanglin avatar toddanglin commented on May 10, 2024 1

For the benefit of this thread, the :highlighted pseudo selector is now supported.

It behaves more or less like the :active selector from the web. You can find more details in this issue: NativeScript/theme#4.

from nativescript.

lscown avatar lscown commented on May 10, 2024

Would be great to see this! Not only would it be good to see for buttons, but also any UI element that has a tap event attached to it. This could extend into applying the Android ripple effect on tap.

We are currently using a stacklayout as a button, because this element can contain child elements (i.e. image and text).

from nativescript.

PanayotCankov avatar PanayotCankov commented on May 10, 2024

We could use these in our QSF 👍

from nativescript.

bradmartin avatar bradmartin commented on May 10, 2024

+1

from nativescript.

NathanWalker avatar NathanWalker commented on May 10, 2024

This would be awesome to see +1

from nativescript.

chromonav avatar chromonav commented on May 10, 2024

+1

from nativescript.

mike-ense avatar mike-ense commented on May 10, 2024

+1

It's not implemented already. I guess the ability to give differentiated color to buttons and then color variation when they're pressed, is extremely high prio.

Is any workaround available in the meantime?

(For instance someone maybe could implement a patch, or a temporary button implementation altogether. I don't understand the internals well enough to have any idea yet.)

from nativescript.

mike-ense avatar mike-ense commented on May 10, 2024

Could I somehow hook into the like "onMouseDown" and "onMouseUp" events and just change the button's .cssClass accordingly -

I can't find any "onpressed" and "onunpressed" events though - what am I missing?

from nativescript.

mike-ense avatar mike-ense commented on May 10, 2024

So those are called MotionEvent.ACTION_UP and MotionEvent.ACTION_DOWN on Android, and those in turn are mapped to the GestureStateType:s "began" and "ended" in the {N} runtime.

But they seem not to be exported to userland currently.

To make history happen faster I open a separate issue for that: #1366 .

Actually if you think about it, a ":pressed" CSS pseudo-class will only alter the CSS applied on a button, so there will be cases when you will want event listeners for this functionality. So I guess the request in that github issue makes a lot of sense.

from nativescript.

sitefinitysteve avatar sitefinitysteve commented on May 10, 2024

Just encountered this now, would be nice :) Had to look at the source to get selectedBackgroundColor on the segmented bar where

SegmentedBar:active{} (or whatever)

Would have been super handy

from nativescript.

mike-ense avatar mike-ense commented on May 10, 2024

Since my comment above here in this issue, touch events were implemented #1383 , so all I wanted can be done programmatically. While of course a ":pressed" pseudoclass would be super-nice, at least the same goal can be reached other ways, so, for me this is not an issue anymore (and things like an SVG renderer are much higher prio).

from nativescript.

vjoao avatar vjoao commented on May 10, 2024

+1 on this. Would be great to have first/last child selectors.

from nativescript.

BenKingBBC avatar BenKingBBC commented on May 10, 2024

Do we still not have :pressed? Would go a long way to making elements feel more native if you could style them while your finger is on them.

from nativescript.

vjoao avatar vjoao commented on May 10, 2024

@BenKingBBC I guess the pressed style is handled by the platform itself (i.e Ripple on Android 5)

from nativescript.

leocaseiro avatar leocaseiro commented on May 10, 2024

That would be nice for repeaters as well. I'm using a repeater to emulate a ListView with headers. However, onTap event doesn't seem natural. It's missing the :pressed or :selected colour.

from nativescript.

FireSt-dead avatar FireSt-dead commented on May 10, 2024

nth-child should handle the various hand-made even/odd implementations:
https://github.com/NativeScript/nativescript-sdk-examples-ng/blob/master/app/listview/creating-listview/creating-listview.component.html#L5
Possibly replacing the .even and .odd selectors with ListView>:nth-child(even) and ListView>:nth-child(odd) without additional code in the xml or html temlpates.

from nativescript.

NathanaelA avatar NathanaelA commented on May 10, 2024

@toddanglin just one clarification; this pseudo selector only supports buttons currently...

from nativescript.

nsndeck avatar nsndeck commented on May 10, 2024

Hi all,
Added support for pseudo states named in this issue:
button: pressed, active and highlighted state (button will enter this state when tap and hold)
view: disabled (isEnabled = false)

For the request from @burkeholland about SegmentedBar:selected state
We introduced a new css property named selected-background-color with following usage:

.segmentedBar {
    selected-background-color: red;
}

So closing issue, if you need some other pseudo class property please open a separate issue, since this one is way too big for reading.

Nedyalko

from nativescript.

karim007 avatar karim007 commented on May 10, 2024

+1

from nativescript.

lock avatar lock commented on May 10, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from nativescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.