P2-E mobile responsive UI

#150
Files changed (1) hide show
  1. app.py +89 -0
app.py CHANGED
@@ -52,6 +52,95 @@ st.set_page_config(
52
  initial_sidebar_state="collapsed",
53
  )
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  # A3-R5D: default-off, benchmark-only startup probe; never blocks the UI.
56
  try:
57
  from core.a3_glm_live_probe import run_startup_probe_if_enabled
 
52
  initial_sidebar_state="collapsed",
53
  )
54
 
55
+
56
+ def inject_mobile_responsive_form_styles() -> None:
57
+ """Improve narrow-screen form readability without changing desktop behavior."""
58
+ st.markdown(
59
+ """
60
+ <style>
61
+ @media (max-width: 760px) {
62
+ /* Keep native Streamlit labels complete on narrow screens. */
63
+ [data-testid="stTextInput"] label,
64
+ [data-testid="stSelectbox"] label,
65
+ [data-testid="stNumberInput"] label,
66
+ [data-testid="stRadio"] label,
67
+ [data-testid="stTextInput"] label p,
68
+ [data-testid="stSelectbox"] label p,
69
+ [data-testid="stNumberInput"] label p,
70
+ [data-testid="stRadio"] label p {
71
+ width: 100% !important;
72
+ max-width: 100% !important;
73
+ min-width: 0 !important;
74
+ white-space: normal !important;
75
+ overflow: visible !important;
76
+ text-overflow: clip !important;
77
+ overflow-wrap: anywhere !important;
78
+ line-height: 1.35 !important;
79
+ }
80
+
81
+ /* Let form widgets use the full available mobile width. */
82
+ [data-testid="stTextInput"],
83
+ [data-testid="stSelectbox"],
84
+ [data-testid="stNumberInput"],
85
+ [data-testid="stRadio"] {
86
+ width: 100% !important;
87
+ max-width: 100% !important;
88
+ min-width: 0 !important;
89
+ }
90
+
91
+ /* Preserve the native Research Design selectbox while allowing long
92
+ selected values to wrap instead of being visually truncated. */
93
+ [data-testid="stSelectbox"] [data-baseweb="select"],
94
+ [data-testid="stSelectbox"] [role="combobox"] {
95
+ width: 100% !important;
96
+ max-width: 100% !important;
97
+ min-width: 0 !important;
98
+ }
99
+
100
+ [data-testid="stSelectbox"] [data-baseweb="select"] > div {
101
+ min-height: 3rem !important;
102
+ height: auto !important;
103
+ }
104
+
105
+ [data-testid="stSelectbox"] [data-baseweb="select"] > div > div:first-child,
106
+ [data-testid="stSelectbox"] [data-baseweb="select"] > div > div:first-child > div,
107
+ [data-testid="stSelectbox"] [data-baseweb="select"] span,
108
+ [data-testid="stSelectbox"] [role="combobox"] span {
109
+ min-width: 0 !important;
110
+ max-width: 100% !important;
111
+ white-space: normal !important;
112
+ overflow: visible !important;
113
+ text-overflow: clip !important;
114
+ overflow-wrap: anywhere !important;
115
+ line-height: 1.3 !important;
116
+ }
117
+
118
+ /* BaseWeb renders the opened select menu in a portal. Keep option
119
+ rows readable for long EN/RU/KK method names on small screens. */
120
+ [data-baseweb="menu"] [role="option"],
121
+ [data-baseweb="popover"] [role="option"] {
122
+ min-height: 2.75rem !important;
123
+ height: auto !important;
124
+ white-space: normal !important;
125
+ overflow-wrap: anywhere !important;
126
+ line-height: 1.3 !important;
127
+ }
128
+
129
+ /* Standard / Flagship may wrap naturally rather than compressing. */
130
+ [data-testid="stRadio"] [role="radiogroup"] {
131
+ flex-wrap: wrap !important;
132
+ row-gap: 0.45rem !important;
133
+ column-gap: 1rem !important;
134
+ }
135
+ }
136
+ </style>
137
+ """,
138
+ unsafe_allow_html=True,
139
+ )
140
+
141
+
142
+ inject_mobile_responsive_form_styles()
143
+
144
  # A3-R5D: default-off, benchmark-only startup probe; never blocks the UI.
145
  try:
146
  from core.a3_glm_live_probe import run_startup_probe_if_enabled