Commit a646fc36fe18e876109f0c6932623b8a617f6b84

Authored by 梁灏
1 parent 2e14b458

optimize box-shadow

use two box-shadow when focus, and a :after to make focus style looks better
Showing 1 changed file with 46 additions and 7 deletions   Show diff stats
src/styles/components/radio.less
... ... @@ -178,34 +178,45 @@ span.@{radio-prefix-cls} + * {
178 178 height: @btn-circle-size;
179 179 line-height: @btn-circle-size - 2px;
180 180 margin: 0;
181   - padding: 0 16px;
  181 + padding: 0 16px - 1px;
182 182 font-size: @font-size-small;
183 183 color: @btn-default-color;
184 184 transition: all @transition-time ease-in-out;
185 185 cursor: pointer;
186 186 border: 1px solid @border-color-base;
187   - //border-left: 0;
  187 + border-left: 0;
188 188 background: #fff;
  189 + position: relative;
189 190  
190 191 > span {
191 192 margin-left: 0;
192 193 }
193 194  
194   - &:before {
  195 + &:before, &:after {
195 196 content: '';
  197 + display: block;
196 198 position: absolute;
197 199 width: 1px;
198 200 height: 100%;
199 201 left: -1px;
  202 + top: 0;
200 203 background: @border-color-base;
201   - visibility: hidden;
  204 + //visibility: hidden;
202 205 transition: all @transition-time ease-in-out;
203 206 }
204 207  
  208 + &:after{
  209 + height: @btn-circle-size + 4px;
  210 + left: -1px;
  211 + top: -3px;
  212 + background: fade(@primary-color, 20%);
  213 + opacity: 0;
  214 + }
  215 +
205 216 &:first-child {
206 217 border-radius: @btn-border-radius 0 0 @btn-border-radius;
207 218 border-left: 1px solid @border-color-base;
208   - &:before {
  219 + &:before, &:after {
209 220 display: none;
210 221 }
211 222 }
... ... @@ -237,11 +248,31 @@ span.@{radio-prefix-cls} + * {
237 248 background: #fff;
238 249 border-color: @primary-color;
239 250 color: @primary-color;
240   - //box-shadow: -1px 0 0 0 @primary-color;
  251 + box-shadow: -1px 0 0 0 @primary-color;
  252 + z-index: 1;
  253 +
  254 + &:before{
  255 + background: @primary-color;
  256 + opacity: 0.1;
  257 + }
  258 +
  259 + &.@{radio-prefix-cls}-focus{
  260 + box-shadow: -1px 0 0 0 @primary-color, 0 0 0 2px fade(@primary-color, 20%);
  261 + transition: all @transition-time ease-in-out;
  262 + &:after{
  263 + left: -3px;
  264 + top: -3px;
  265 + opacity: 1;
  266 + background: fade(@primary-color, 20%);
  267 + }
  268 + &:first-child{
  269 + box-shadow: 0 0 0 2px fade(@primary-color, 20%);
  270 + }
  271 + }
241 272  
242 273 &:first-child {
243 274 border-color: @primary-color;
244   - //box-shadow: none!important;
  275 + box-shadow: none;
245 276 }
246 277  
247 278 &:hover {
... ... @@ -287,6 +318,9 @@ span.@{radio-prefix-cls} + * {
287 318 height: @btn-circle-size-large;
288 319 line-height: @btn-circle-size-large - 2px;
289 320 font-size: @font-size-base;
  321 + &:after{
  322 + height: @btn-circle-size-large + 4px;
  323 + }
290 324 }
291 325  
292 326 .@{radio-group-button-prefix-cls}.@{radio-group-prefix-cls}-small .@{radio-prefix-cls}-wrapper{
... ... @@ -294,6 +328,11 @@ span.@{radio-prefix-cls} + * {
294 328 line-height: @btn-circle-size-small - 2px;
295 329 padding: 0 12px;
296 330 font-size: @font-size-small;
  331 +
  332 + &:after{
  333 + height: @btn-circle-size-small + 4px;
  334 + }
  335 +
297 336 &:first-child {
298 337 border-radius: @btn-border-radius-small 0 0 @btn-border-radius-small;
299 338 }
... ...