File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 44
55A simple rating library for react native supporting:
66
7+ -  ** a11y ready**  ⚛️
78-  ** decimal points**  like 3.7, 4.2 etc,
89-  ** direction aware**  icons (like you can pass direction as “column” or “row-reverse”),
910-  ** custom icon set**  from Ionicons,
Original file line number Diff line number Diff line change @@ -25,9 +25,15 @@ const IconBar = ({
2525  selectedIconImage, 
2626  emptyIconImage, 
2727  filled =  false , 
28+   totalCount, 
29+   isAccessible, 
2830} )  =>  ( 
2931  < TouchableOpacity 
3032    activeOpacity = { 1 } 
33+     accessible = { isAccessible } 
34+     importantForAccessibility = { isAccessible  ? "yes"  : "no" } 
35+     accessibilityLabel = { `Press to rate ${ position  +  1 }   out of ${ totalCount }  ` } 
36+     accessibilityRole = "button" 
3137    onPress = { ( )  =>  { 
3238      if  ( ! readonly )  { 
3339        onIconTap  &&  onIconTap ( position  +  1 ) ; 
@@ -58,6 +64,7 @@ IconBar.propTypes = {
5864  type : PropTypes . oneOf ( [ "icon" ,  "custom" ] ) , 
5965  selectedIconImage : PropTypes . node , 
6066  emptyIconImage : PropTypes . node , 
67+   totalCount : PropTypes . number , 
6168} ; 
6269
6370export  default  IconBar ; 
Original file line number Diff line number Diff line change @@ -46,10 +46,15 @@ const Rating = ({
4646  const  percentage  =  ( rated  /  totalCount )  *  100 ; 
4747
4848  return  ( 
49-     < StyledView  dir = { direction } > 
49+     < StyledView 
50+       dir = { direction } 
51+       accessible = { ! readonly } 
52+       importantForAccessibility = { ! readonly  ? "yes"  : "no" } 
53+     > 
5054      < BackgroundIcons  dir = { direction } > 
5155        { Array . from ( {  length : totalCount  } ,  ( _ ,  i )  =>  ( 
5256          < IconBar 
57+             isAccessible 
5358            name = { icon } 
5459            key = { `bgstar_${ i }  ` } 
5560            size = { size } 
@@ -61,6 +66,7 @@ const Rating = ({
6166            type = { type } 
6267            selectedIconImage = { selectedIconImage } 
6368            emptyIconImage = { emptyIconImage } 
69+             totalCount = { totalCount } 
6470          /> 
6571        ) ) } 
6672        < ColoredIcons  percentage = { percentage }  dir = { direction } > 
@@ -78,6 +84,7 @@ const Rating = ({
7884              type = { type } 
7985              selectedIconImage = { selectedIconImage } 
8086              emptyIconImage = { emptyIconImage } 
87+               totalCount = { totalCount } 
8188            /> 
8289          ) ) } 
8390        </ ColoredIcons > 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments