Skip to content

Commit

Permalink
Merge pull request #1211 from Wizleap-Inc/feat/1198_input
Browse files Browse the repository at this point in the history
base-inputのFocusの色をデフォルトのものにする
  • Loading branch information
ichi-h authored Feb 22, 2024
2 parents cfdec06 + 7142f41 commit f1e5df1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .changeset/seven-carrots-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@wizleap-inc/wiz-ui-react": patch
"@wizleap-inc/wiz-ui-next": patch
"@wizleap-inc/wiz-ui-styles": patch
---

[#1198] focus 時の色をブラウザーデフォルトのものに修正
3 changes: 0 additions & 3 deletions packages/styles/bases/base-input.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export const baseInputStyle = style({
color: THEME.color.gray[500],
fontSize: `calc((${THEME.fontSize.sm} + ${THEME.fontSize.xs}) / 2)`,
},
":focus": {
outline: "none",
},
});

export const baseInputPaddingStyle = styleVariants({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
baseInputPaddingStyle,
} from "@wizleap-inc/wiz-ui-styles/bases/base-input.css";
import { inputBorderStyle } from "@wizleap-inc/wiz-ui-styles/commons";
import { computed, ref, PropType } from "vue";
import { computed, PropType } from "vue";
defineOptions({
name: ComponentName.BaseInput,
Expand Down Expand Up @@ -91,22 +91,17 @@ const textValue = computed({
set: (value) => emit("update:modelValue", value),
});
const hasFocus = ref(false);
const computedWidth = computed(() => (props.expand ? "100%" : props.width));
const state = computed(() => {
if (props.error) return "error";
if (hasFocus.value) return "active";
return "default";
});
const onFocusIn = (e: FocusEvent) => {
hasFocus.value = true;
emit("focusin", e);
};
const onFocusOut = (e: FocusEvent) => {
hasFocus.value = false;
emit("focusout", e);
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import { ComponentName } from "@wizleap-inc/wiz-ui-constants";
import * as styles from "@wizleap-inc/wiz-ui-styles/bases/base-input.css";
import { inputBorderStyle } from "@wizleap-inc/wiz-ui-styles/commons";
import { clsx } from "clsx";
import {
ComponentProps,
ForwardedRef,
forwardRef,
memo,
useState,
} from "react";
import { ComponentProps, ForwardedRef, forwardRef, memo } from "react";

import { BaseProps } from "@/types";
type Props = BaseProps & {
Expand Down Expand Up @@ -41,11 +35,8 @@ const _PrivateBaseInput = forwardRef(
}: Props,
ref: ForwardedRef<HTMLInputElement>
) => {
const [hasFocus, setHasFocus] = useState(false);

const state = (() => {
if (error) return "error";
if (hasFocus) return "active";
return "default";
})();

Expand All @@ -66,11 +57,9 @@ const _PrivateBaseInput = forwardRef(
type={type}
id={id}
onFocus={(e) => {
setHasFocus(true);
props.onFocus?.(e);
}}
onBlur={(e) => {
setHasFocus(false);
props.onBlur?.(e);
}}
onChange={props.onChange}
Expand Down

0 comments on commit f1e5df1

Please sign in to comment.